KABUL — A sweeping Taliban offensive across northern Afghanistan, unchecked by overstretched government forces, has triggered a sudden resurgence of anti-Taliban militias in half a dozen provinces, raising concerns that the country could plunge into a prolonged civil war.

President Ashraf Ghani, scheduled to visit Washington on Friday to meet with President Biden amid growing concerns here about the withdrawal of U.S. forces, has endorsed the sudden call to arms by former ethnic rival groups and shaken up his top security team, in hopes of stemming the Taliban onslaught and calming public panic.

In a meeting Monday with influential former anti-Soviet and anti-Taliban militia leaders, Ghani called on them to create a “united front” and support the Afghan security forces to “strengthen peace” and “safeguard the republic system.” The Taliban rejects the current democratic governing system and seeks to install an Islamic one.

During a separate ceremony, the newly appointed acting defense minister, Bismillah Khan Mohammadi, called on “my patriots and people everywhere to stand alongside their security and defense forces.” He said the government is “ready to provide them with all equipment and resources.”

The Ghani government hopes the added support will shore up the beleaguered national defense forces, which have struggled to send reinforcements and supplies to troops facing repeated Taliban attacks.

But the prospect of unleashing a hodgepodge of rogue warriors to repel their old enemies also raises the specter of civil war, a state of violent anarchy that Afghans remember all too well from the 1990s. And although the armed groups have pledged to coordinate with government forces, it is also possible that effort could unravel into confused, competing clashes among purported allies.

“The surge in militias is a recipe for disaster and a repetition of a dark history,” said Tamim Asey, chairman of the Institute of War and Peace Studies in Kabul. “It will enlarge ethnic fault lines and undercut government legitimacy.” He said that relying on the militias is a “poison pill” that might give Ghani short-term relief but will ultimately “kill his administration.”

Atta Mohammed Noor, a northern warlord and former governor, posted a tweet Monday calling for a “national mobilization” of former anti-Soviet groups to fight Taliban aggression. He called on all northern factions to “stand alongside” state forces, and in a separate Facebook post he asked their leaders to join in the fight without creating separate “islands of power.”

In the past several days, fighting has been reported in nine provinces across the north, and armed militias or civilian groups have formed to repel the insurgents, often fighting alongside state forces. All are loyal to local leaders from minority Tajik, Uzbek or other ethnic groups that have no love for Ghani, a member of the dominant ethnic Pashtun group based in southern Afghanistan.

In Kunduz province, a strategic area near the northern border with Tajikistan, several officials there said Tuesday that insurgents were fighting against local forces inside the provincial capital city and were either attacking or in control of most rural districts. They also seized a dry port on the border. The Taliban has tried several times in the past to take over Kunduz city and held it briefly in 2015. If the group were to take over the city, it would be a major turning point in the 20-year conflict.

“The city is under attack,” said Ghulam Rabani, a member of the provincial council, reached in Kunduz city Tuesday evening. He said that local fighters and government forces were defending the city and had recaptured one rural district but that “all others are now ruled by the Taliban.”

Taliban fighters took control of a key district in Afghanistan's northern Kunduz province on June 21 and encircled the provincial capital, police said. (The Washington Post)

Since May, the Taliban has seized more than 50 of Afghanistan’s 370 districts. On Tuesday, the U.N. special envoy to Afghanistan, Deborah Lyons, told the U.N. Security Council that many of those districts surround provincial capitals, suggesting that the insurgents are “positioning themselves to try and take those capitals once foreign forces are fully withdrawn.” Across the nation, scattered fighting has been reported this week in 20 provinces.

The Taliban, historically based in the parched southern region that includes Kandahar, Helmand and Uruzgan provinces, has repeatedly tried to capture major cities there in the past several years. The group’s attacks in the north have greatly intensified in recent months, taking advantage of the relative lack of government forces. At the same time, Taliban peace talks with Afghan leaders in Qatar have stalled.

The most significant confrontation this week has come in Mazar-e Sharif, the country’s fourth-largest city and the capital of Balkh province, long impregnable to Taliban threats. Insurgents breached the city Monday and were pushed back by a mix of local militias and national forces, but area residents remained frightened, and the insurgents posed for videos just outside the city gates.

“People here have enjoyed a peaceful life for 20 years. Now they are very worried,” said Mohammad Afzal Hadid, head of the Balkh provincial council, noting that seven districts in the province had fallen to the Taliban in the past month. “Government forces lost morale. Bases were falling one after another.” He said that public fear had died down after local militia members came to reinforce government troops, and that hundreds more were preparing to join the fight.

A former Balkh council member, Mohammad Khairandesh, dismissed concerns about the private militias going rogue, saying they were now defending the state rather than themselves. The public, he added, accepts them as a lesser evil. “People now prefer militias over the Taliban,” he said. Without their help, he said, “there is a possibility that Mazar may fall.”

In Baghlan province, where the Taliban captured six districts in the past three weeks, officials blamed poor management and leadership of government forces but said that former militia members are preparing to fight. One provincial council member, Ferozuddin Aimaq, said people are “mobilizing to support government forces” but will “rise up against the Taliban if the government collapses.”

Ahmad Zia Massoud, a former vice president and younger brother of the slain anti-Soviet and anti-Taliban leader Ahmad Shah Massoud, posted a Facebook message Tuesday calling on “all political leaders” in the country to “join the front lines alongside the people and public uprising forces.”

Meanwhile, on the front lines of Baghlan’s Tala Wa Barfak district, Naimatullah Pajwalk, the district chief, spent Tuesday shoring up checkpoints. He said the area had been attacked five times by insurgents in the past 10 days.

“It is chaos, but here the people and the forces are mobilized,” he said. “The Taliban are trying hard to capture this district because it would give them connections to other provinces.”

Pajwalk said that the attackers had Humvees and heavy weapons seized from surrendering government troops, and that they had spread false rumors that he and other officials had fled.

“We are under immense pressure,” he said, “but we will stay with our people until the last drop of blood.”

Sharif Hassan contributed to this report.