As the Taliban leadership closed in on forming a government Wednesday, its fighters were attacking the last bastion of Afghanistan not under their control, seeking to consolidate their military and political grip on the country.

In northern Afghanistan, heavy fighting erupted Tuesday night and continued into Wednesday. Meanwhile, the Taliban leadership met in its southern spiritual birthplace of Kandahar to discuss the formation of an Islamic government. It’s a major step that will formalize the Taliban’s transition from an insurgent movement to once again ruling the country after the 20 years of war that followed the Sept. 11, 2001, attacks on the United States.

The three-day-long engagement was chaired by Sheikh Haibatullah Akhundzada, a religious scholar who is widely expected to become the country’s supreme leader, suggesting the new government could be structured much like Iran’s theocracy.

Other senior leaders, such as Abdul Ghani Baradar, a co-founder of the Taliban, Sirajuddin Haqqani, a powerful deputy leader of the militants, and Mawlawi Muhammad Yaqoub, the son of Muhammad Omar, the Taliban’s late leader, are also expected to hold influential posts in the new government.

Yet Taliban officials on Wednesday kept the composition of the new government under wraps, refusing to confirm reports about the role of Akhundzada and other leaders. Also unclear was whether the country’s former president, Hamid Karzai, and Abdullah Abdullah, a top politician who led the High Council for National Reconciliation, would receive high-level posts in the new government.

The Taliban has promised an inclusive government made up of Afghans from different backgrounds and ethnicities, including women. Karzai and Abdullah, who remained in the country when President Ashraf Ghani and his top aides fled, are seen as influential figures who can help smooth the transition to Taliban rule and reassure Afghans who fear being oppressed and denied basic liberties by the Taliban.

Zabihullah Mujahid, a Taliban spokesman, said “some decisions were made” about the country’s political and social affairs, as well as “necessary consultations” about forming the new government and cabinet.

Another Taliban spokesman, Bilal Karimi, said the meetings did not include non-Taliban leaders. “There was no talk about including or not including” anti-Taliban leaders in the new government, he said. “The new government will be announced in the next few days.”

In Kabul, the Ministry of Information and Culture was preparing for a ceremony in the presidential palace, said Ahmadullah Muttaqi, a Taliban official. “Now, I can’t say who is going to be the leader, but we will have a government,” he said.

Whatever its composition, any new government will immediately face a cascade of daunting challenges in a nation of 40 million battered by war and an economy in turmoil, where hundreds of thousands have fled their homes and are living in dire poverty. The United Nations is already warning of severe food shortages that could touch off a massive humanitarian crisis.

Meanwhile, the war is not completely over.

The night after U.S. forces left Afghanistan entirely, battles in the holdout Panjshir Valley killed 17 resistance fighters, Fahim Qiami, a spokesman for the loosely organized National Resistance Front, said by phone. He also claimed that 41 Taliban fighters were killed.

A Taliban fighter in the region, who spoke on the condition of anonymity because he was not authorized to speak to the media, denied that the Taliban suffered any casualties. He told The Washington Post that Taliban forces took control of one district in Panjshir province and were close to quashing the last resistance.

“We are receiving encouraging reports from the mujahideen who are fighting with the Massoud forces,” the fighter said, referring to Ahmad Massoud, leader of the opposition fighters in the region.

The anti-Taliban resistance has been rallying under Massoud, son of legendary guerrilla commander Ahmad Shah Massoud, who was assassinated in 2001.

Fighting in Panjshir broke out after talks aimed at securing a peaceful solution collapsed Monday. The Taliban has been sending reinforcements to the region.

Amir Khan Muttaqi, a senior Taliban leader who has been negotiating with former government officials in Kabul, said Wednesday that the takeover was all but complete.

“Dear brothers, as you know, we have control over Afghanistan from Badakhshan to Helmand, and Herat to Jalalabad. There is complete peace and stability,” Muttaqi said in a recorded statement released on social media. “All invaders have left Afghanistan. This is a historic moment for all Afghans, who all feel a sense of pride.”

Muttaqi called on the final resistance holdouts to lay down their weapons and said the Taliban would extend a general amnesty to them. “I extend the full guarantee on behalf of the Islamic Emirate that the Islamic Emirate is your home.”

The Panjshir has long been an anti-Taliban stronghold; it was the only region of the country never conquered by the Islamist group during its previous rule, from 1996 to 2001. In recent weeks, opposition leaders there and some officials from the fallen government have tried to marshal forces to hold off the Taliban advance.

The fighting continued into Wednesday morning, according to a Panjshir resident who recently relocated to Kabul.

“I talked to my relatives in my hometown,” he said by phone. “They say huge blasts and gunshots have been heard since last night.”