KABUL—The Taliban captured the capital of the strategic Samangan province on Monday after a prominent pro-government commander switched sides, nearly completing their sweep of northern Afghanistan and intensifying a political crisis in Kabul.

The bloodless takeover of Aibak, which followed the seizure of four other nearby provincial capitals in the past three days, has allowed Taliban forces to unite in an assault on the biggest prize: northern Afghanistan’s main metropolis of Mazar-e-Sharif. Taliban forces attacked the now-isolated city of half a million people from different directions on Monday, but so far haven’t made significant inroads. Separately, insurgents battled government forces inside western Afghanistan’s main city of Herat.

The dizzying series of battlefield losses is fueling calls for President Ashraf Ghani —who has relied on a narrow circle of advisers and frequently changed key ministers and military commanders—to change how he governs or step aside. Kabul could fall to the Taliban within a few weeks unless all political forces opposed to the insurgency unite behind a common war plan, a senior government member warned.

After two nights of heavy fighting, Taliban forces seized the city of Kunduz and went on to overtake two other provincial capitals on Sunday. Photo: Abdullah Sahil/AP The Wall Street Journal Interactive Edition

In the months since President Biden announced in April his decision to withdraw all U.S. troops from Afghanistan, the Taliban has launched a lightning offensive across the country. That is despite their commitment to seek a peaceful settlement in the February 2020 Doha agreement with the Trump administration. Afghanistan’s U.S.-funded and U.S.-trained security forces have often melted away, and the main resistance to the Taliban has come from commando units, the National Directorate of Security intelligence agency, and militias affiliated with mujahedeen warlords.

“There is no motivation for the army to fight for the corrupt government and corrupt politicians here,” said Ahmad Wali Massoud, a former Afghan ambassador to London and a brother of legendary mujahedeen commander Ahmad Shah Massoud, who was assassinated by al Qaeda in 2001. “They are not fighting for Ghani. They haven’t even been fed properly. Why should they fight? For what? They are better off with the Taliban, which is why they are switching sides like that.”

Displaced Afghans sought refuge in a public park in Kabul on Monday.

Photo: Rahmat Gul/Associated Press

Mr. Ghani has been issuing wildly optimistic statements as government control collapsed in much of the country in recent weeks. On Saturday, as the Taliban began seizing provincial capitals, he held a lengthy conference on reforming the attorney-general’s office and then another meeting on implementing digitization reforms in the country’s public administration. On Monday, he had a series of meetings with power-brokers and mujahedeen commanders, and said that anti-Taliban “uprising” militias will be equipped and supported “within the government framework.”

While low-level commanders surrendered to the Taliban before, Monday’s defection by Asif Azimi, a former senator from Samangan and a prominent warlord in the mostly ethnic Tajik Jamiat-e-Islami party, represented the most significant such shift so far. Mr. Azimi’s move could set off a domino effect as other power-brokers, convinced of the inevitability of a Taliban victory, rush to cut their own side deals. Jamiat-e-Islami, under the leadership of Ahmad Shah Massoud, was the driving force of the anti-Taliban Northern Alliance before the 2001 U.S. invasion.

Reached by phone in Samangan, Mr. Azimi said that Jamiat-e-Islami had been established with the aim of fostering Islamic rule when it fought against the Soviet-backed regime in the 1980s, and strayed from this path by aligning itself with the U.S. after 2001.

People stranded at the Pakistani-Afghan border waited for the crossing to reopen after the Taliban closed it.

Photo: akhter gulfam/Shutterstock

“We want an Islamic government. This government is a puppet of America. Anyone who stands against it, we will support it,” Mr. Azimi explained his decision to back the Taliban. He said hundreds of men under his command followed suit.

In western Afghanistan, the Taliban on Monday tightened their siege of the region’s main city of Herat, which they have been attacking from three sides. With few regular forces left in Herat, militiamen loyal to warlord Ismail Khan have been leading the fight there. “It’s still a war situation in the city,” said one of the commanders loyal to Mr. Khan, Abdul Razaq Ahmadi. “The Taliban have mobilized all their forces from surrounding provinces, including foreigners, to take the city.”

Insurgents took over the city’s outer neighborhoods on Monday, close to its historic 15th century minarets, said a resident, Atiqullah Mutmaeen. Over the past few weeks, the city has emptied out on flights to Kabul or over roads to the Iranian border. The Taliban have repeatedly cut the road between the city and the airport. Airstrikes against the Taliban have become difficult because of dust storms and because insurgents are now inside the city’s built-up areas, he added. “People who have the money to leave have already done it,” Mr. Mutmaeen said.