A devastating Taliban attack on an Afghan army base last week has shaken up the government here, forcing the resignations of the country’s defense minister and army chief on Monday as Defense Secretary Jim Mattis arrived in a surprise visit to survey the deteriorating situation.

The Taliban, which is contesting control of one-third of Afghanistan, has continued to steadily gain territory and inflict record casualties on civilians and troops since most NATO troops withdrew from the country in 2014. The assault Friday — following a winter of repeated Taliban attacks on strategic cities and towns — adds to concerns that Afghanistan will not be able to defend itself without a major commitment of U.S. support.

With the conflict at a stalemate and no sign that peace talks will resume after several years of failed attempts, it is far from clear whether the Trump administration will decide to make a significant contribution in troops and money.

But the continued weakness of the Afghan military adds urgency to a request from Gen. John Nicholson, in charge of U.S. forces here, for additional troops. Nicholson has told Congress that about 3,000 more troops are needed to prop up the security forces in Afghanistan. The White House is conducting a review of the U.S. strategy in Afghanistan, including troop levels, headed by national security adviser H.R. McMaster.

About 8,400 U.S. troops are currently advising and training local forces, conducting counterinsurgency operations and providing air combat and evacuation support. By comparison, at the height of the war, more than 100,000 U.S. forces were stationed here.

In an assault Friday marked by ruthlessness and stealth, a handful of Taliban fighters managed to enter a base teeming with soldiers and kill at least 140 of them shortly after the weekly prayer service there.

The attack at a base in northern Balkh province, the deadliest carried out by the Taliban against the military in 16 years of fighting, belied Afghan insistence that the country’s troubled defense forces are moving toward self-sufficiency after years of relying on Western allies to fund, train and equip them.

The attackers, who penetrated the base wearing army uniforms and kept fighting for more than five hours, were finally quelled by an Afghan commando force. That scenario has been repeated in numerous other battlefronts, where the elite units replaced police and regular troops who were unable to fend off insurgent fighters. 

While the commandos were singled out for praise Saturday by Nicholson, the defense forces overall, totaling more than 700,000 men, remain plagued by poor coordination, illiteracy, high rates of attrition, defections to the Taliban, ethnic infighting, and widespread corruption that includes the theft and resale of combat supplies meant for front-line troops.

The weaknesses that have left heavily subsidized Afghan forces struggling to fend off much smaller numbers of insurgents have become increasingly difficult to excuse, as indicated by the highly unusual resignations of Defense Minister Abdullah Habibi and Army Chief of Staff Qadam Shah Shahim on Monday.

“No one has put pressure on me. I have resigned for the national interest of the country,” Habibi told reporters. Shahim also said he stepped down voluntarily. President Ashraf Ghani accepted both resignations immediately and replaced three other army commanders, a move that some analysts praised as necessary to boost military morale and public trust. 

Other recent major attacks claimed by the Taliban or Islamic State include the invasion of a military hospital in Kabul on Mar. 8 that left at least 30 people dead, and a one-day spate of scattered bombings Jan. 10 that killed 65 people, including three Emirati diplomats at a government guesthouse in Kandahar.

U.S. Defense Secretary Jim Mattis checks his watch as he arrives via helicopter at Resolute Support headquarters in Kabul, Afghanistan, on April 24. (Jonathan Ernst/AP)

An adviser to the governor of Balkh, Tahir Qaderi, said the death toll from Friday’s attack could be as high as 200. He said most of those who died were fresh recruits, and he attributed the high casualty numbers to incompetence and ignorance. “Some of them had not taken a rifle in their hand in their lifetime,” he said.

Nicholson said Monday that the Taliban appears to be receiving weapons from Russia, further complicating the war and the Trump administration’s relationship with the Kremlin.

“We support anyone who wants to help us advance the reconciliation process,” said Nicholson, speaking to reporters alongside Mattis on Monday. “But anyone who arms belligerents who perpetuate attacks like the one we saw two days ago . . . is not the best way forward to a peaceful reconciliation.”

In addition, the two-sided role of next-door Pakistan in the conflict remains a major frustration for Washington as President Trump and his aides develop a policy toward the longtime Cold War and anti-terrorism ally.

Nicholson said the sophistication of Friday’s attack suggested it was “quite possible” that the gunmen were linked to the Haqqani network, a Taliban splinter faction based in Pakistan. Nicholson and other U.S. military leaders have strongly criticized Pakistan for harboring the Haqqani group, which Pakistan denies.

In another apparent Taliban strike Monday, a car bomb exploded outside Camp Chapman, a base used by the U.S. military and others. A U.S. military spokesman here, Capt. William Salvin, said there were some Afghan casualties, but none among U.S. or coalition personnel, the Associated Press reported.

Camp Chapman, near the Pakistani border south of Kabul, was the scene of a suicide bombing in 2009 that killed seven CIA officers and contractors.

Mattis, who last visited Afghanistan in 2013 when he was a Marine general and leader of the U.S. Central Command, is wrapping up his six-nation trip through the Middle East and the Horn of Africa.

The deterioration in security has been partly blamed on protracted rivalry and paralysis within the Afghan government, a power-sharing arrangement between Ghani and his former election rival, chief executive Abdullah Abdullah. Their national unity government came to power in 2014.

Constable reported from Islamabad. Sharif Walid in Kabul and Missy Ryan in Washington contributed to this report.