Zaki was among thousands of Afghans who fled into the craggy mountains north of Kabul following the Taliban’s rapid takeover of Afghanistan, fearing the brutality and harsh rules of the Islamist extremists. Now, the 27-year-old former government employee is carrying an AK-47 on Afghanistan’s last military front line.

College-educated, the civilian-turned-guerrilla fighter is part of a fledgling resistance force determined to prevent the Taliban from seizing the last sliver of Afghanistan the militants have yet to dominate — the rugged province of Panjshir.

“We do not want to be second- or third-class citizens of the country,” said Zaki, who spoke on the condition that his full name not be used because he fears reprisals by the Taliban against his family in Kabul. “We do not want to lose our freedom and our smile.”

For the past four days, the Taliban has targeted Panjshir, attacking from several directions and engaging in fierce clashes with the resistance forces. It is the most serious challenge the Taliban has faced in the military campaign in which it swept across Afghanistan last month in a lightning strike that saw Kabul and 33 provincial capitals fall in 10 days.

Both sides say they have inflicted heavy battlefield casualties and have claimed successes, and both are using social media to spread disinformation.

Despite the resistance’s control of most of the province, it remains unclear whether it will gain traction or be swiftly crushed by a resurgent Taliban, whose forces on Thursday night appeared to be advancing into some parts of Panjshir.

The violence erupted after efforts to negotiate a power-sharing deal with resistance leaders broke down last week.

“The Taliban mind-set is not for talks, not for peace,” said Ahmad Wali Massoud, a former Afghan ambassador to Britain. “They think that they have captured Afghanistan and so, therefore, Panjshir must surrender. But the people who are fighting want to defend their homeland, their territory, their families and their lives. What’s happening in Panjshir is a resistance for all of Afghanistan.”

For the Taliban, the uprising is an unwelcome deja vu of sorts, arriving as the militants form a government and seek international legitimacy. When the Taliban first captured the Afghan capital, in 1996, and controlled the country until 2001, its fighters were never able to take control of Panjshir, despite repeated attempts.

The resistance then was led by Massoud’s brother, Ahmed Shah Massoud, a storied Afghan mujahideen commander known as the “Lion of Panjshir,” who helped expel the Soviets in the 1980s. He was assassinated by al-Qaeda operatives two days before the Sept. 11, 2001, attacks on the United States.

Today, the guerrillas, known as the National Resistance Front, are led by Ahmed Shah Massoud’s 32-year-old son, Ahmad Massoud, who was educated in Britain, including at the Royal Military Academy at Sandhurst, but has no battlefield experience.

The younger Massoud faces a far different military and geopolitical landscape. The Taliban outnumbers his forces dramatically, is militarily far superior and is flush with American-made weaponry seized from the former government’s army, whose troops surrendered in droves to the advancing militants.

Unlike his late father, who received extensive military aid from the United States and other Western powers, Massoud has received no international support, particularly from a Washington humiliated by the outcome of 20 years of war against the Taliban.

The elder Massoud also had supply routes from neighboring Tajikistan to support his guerrilla army. This time, the Taliban controls all the northern border provinces and can block supply routes.

Despite those disadvantages, resistance leaders say they have geography on their side. Panjshir is a vast mountainous region whose southern end lies roughly 100 miles northeast of Kabul. Nestled in the Hindu Kush mountains, it is filled with narrow ravines and rock formations that create a natural bulwark against invaders and a perfect environment for ambushes and guerrilla warfare.

“Our strategic position is being in the Panjshir,” said Ali Nazary, head of foreign relations for the National Resistance Front. “The Panjshir is fortified. The terrain is not friendly to outsiders who want to invade.”

He said the Soviets were repelled nine times when they tried to take the region in the 1980s. And in the 1990s, he added, the Taliban had a bigger military advantage because they had rocket launchers, scud missiles and jets to bomb the rebels, yet never succeeded in seizing the province.

The resistance forces, Nazary said, number around 10,000. They include local militias and residents of Panjshir, along with volunteers from other provinces. A significant number of former Afghan army soldiers, special forces troops and commandos also have joined, he said.

So has Amrullah Saleh, the country’s former vice president, who arrived in Panjshir shortly after President Ashraf Ghani fled the country as the Taliban entered Kabul. Saleh claims he’s the rightful leader of Afghanistan and has encouraged his followers to come to Panjshir and join the resistance.

Some fighters, such as Zaki, are civilians who have transformed themselves into guerrillas.

Zaki said that two decades of Western support to Afghanistan allowed him to attend university and see the benefits of a society with basic rights and freedoms. And as an ethnic Tajik, he added, he was concerned about the Taliban, who are mostly ethnic Pashtun, targeting other minorities.

“I went to university where I learned freedom,” he said. “It is a historic duty of mine. The Taliban is pushing ethnic agendas.”

Even as his fighters clash with the Taliban, the younger Massoud and his top aides insist that they prefer dialogue to reach a power-sharing agreement. They want a decentralized, federal system of governance in which power is equally distributed among Afghanistan’s diverse ethnic groups.

“Anything less than this will be unacceptable to us, and we will continue our struggle and resistance until we achieve justice, equality, and freedom,” Massoud told Foreign Policy magazine this week in an email interview.

The Taliban has rejected such demands and is expected to announce a new government that appears modeled after Iran’s theocracy, with top Taliban religious and military leaders in key positions.

On Thursday, Muhammad Bilal Karimi, a Taliban spokesman, said the militants still wanted to “resolve the issue through peaceful negotiations, but if there is a need for military means, it will take no time to capture this area. Panjshir is surrounded by mujahideen from all sides, and it will take no time to defeat the enemies.”

Nazary said the resistance forces are ready: “If they are going to use aggression, then we’ll use force. The past four days has shown we are able to use force.”

The Taliban is using multiple tactics to break the resistance. In Kabul, Taliban fighters are searching houses in at least three neighborhoods inhabited mostly by ethnic Tajiks, looking for those suspected of having ties to the resistance, said two sources.

“The Taliban arrested 10 people today,” said a civil society activist, who spoke on the condition of anonymity out of security concerns.

The militants also have cut off phone and Internet service as well as access to other basics in parts of Panjshir. “Taliban fighters have blocked food, shut down electricity,” said Ahmad Hashimi, a local clerk in Panjshir, in a telephone interview. “People lack all basic services, including gas.”

But he said he and other residents remained defiant.

“The inhuman acts of the Taliban will not make people bow to them,” he said.