Afghan soldiers of the 4th infantry brigade, 6th Battalion in the village of Baba in Afghanistan's volatile Chak Valley on Dec. 10, 2014. (Sudarsan Raghavan/The Washington Post)

Clutching M-16 rifles, the Afghan soldiers nervously stood watch on a sand-colored ridge next to a mud house blown apart by gunfire. A week earlier, their unit had pushed the Taliban from this village. Now, the insurgents were only a mile away, determined to recapture the territory.

Every day, the 15 soldiers have felt the pressure — and their own limitations.

“They are opening fire on us during the night, even just last night,” said Sgt. Mohammad Mirwais. “We are not enough to protect the village from the Taliban.”

Since March, Mirwais’s Afghan army battalion has been steadily confronting the Taliban in the Chak Valley, southwest of the capital, Kabul. Their performance has been a rare sliver of success in an unprecedented year of death and anguish for the country’s security forces.

But even here, pushing back the insurgents is a grinding and treacherous task. The unit’s experience is a portent of how Afghanistan’s 13-year-old war could shape up in the months after the formal end of the U.S.-led combat mission. Beginning next year, Afghan forces will assume full sovereignty over security with the help of a much smaller — and restricted — NATO presence.

In this valley, the Taliban has retreated only 18 miles since Afghan forces launched an operation nine months ago, and the insurgents still control a large area. No longer aided by U.S. forces and their air support, the Afghan battalion is struggling to hold on to its gains in a landscape where front lines are blurred and the enemy melds into the terrain. The force grapples with shortages of manpower and equipment and a population that has little faith in its ability.

Even as they proclaim success, Afghan commanders here in strategic Wardak province warn that the withdrawal of most American and international forces at the end of the month is premature.

“From a military perspective, it’s too early for them to leave,” said Col. Sami Badakhshani, second in command of the Afghan army’s 4th Infantry Brigade. “We need more armored vehicles, more tanks. We need better training. . . . We don’t have enough soldiers to fill in the gap when the foreign troops leave.”

The stakes are high. Whoever controls the Chak Valley could control the fate of the capital next year. The area flanks the Kabul-Kandahar highway, a key gateway to the city. Many of the roughly 13,000 U.S. and international troops that will remain after the drawdown will be based in Kabul.

The Taliban has grown bolder in recent months, targeting the country’s roughly 380,000 security forces on numerous fronts and seizing territory outside its traditional strongholds. About 5,000 Afghan security-force members have been killed this year, a record number that exceeds the total coalition death toll since the U.S.-led invasion in 2001.

Last month, Afghan soldiers in Helmand province barely fended off a Taliban assault on Camp Bastion, a former British base handed over to the Afghans in October. And in Kabul, Taliban suicide bombers have unleashed a wave of deadly attacks in recent weeks, despite the presence of thousands of Afghan soldiers and police.

“It is going to be tough,” said Lt. Gen. Joseph Anderson, who departed this month as the last U.S. commander to lead combat operations in Afghanistan. “The criticality for the [Afghan forces] is how they use this winter to reset, rearm, re-fit and to get ready for 2015.”

But in the Chak Valley, as in other parts of the country, the fighting season has stretched into the cold winter months, bringing no respite for the besieged Afghan forces.

Fighting over Wardak

Wardak has long been contested territory. The Taliban and the Haqqani network, a Taliban affiliate linked to al-Qaeda, have had a presence here for years.

In the spring of 2013, then-President Hamid Karzai ejected all U.S. Special Forces from Nerkh district, which borders Chak, after accusing American soldiers of involvement in war crimes. That summer, the coalition handed control of Wardak to Afghan forces. Soon after, the Taliban overran the Chak Valley.

This year, Lt. Col. Mohammad Dawood — the U.S.-trained commander of the Afghan army’s 4th Infantry Brigade, 6th Battalion — launched an ambitious offensive against the Taliban.

Initial American air support scattered the militants. Then, Dawood targeted village after village, slowly forcing the insurgents to retreat. More than 50 of his brigade’s men have been killed in combat here and in other parts of the province.

“This is a very dangerous area to control, but somehow I have managed,” said the ruddy-faced Dawood, who first tasted war combating the Soviet occupation in the 1980s.

In an interview, Taliban spokesman Zabiullah Mujahid said that the Taliban still rules most of the valley and that Afghan forces have influence only over the district center.

What is clear is that any territorial gain here is fragile. The battalion’s 300 soldiers are stretched thin across the valley, deployed in several small outposts. A week ago, the Taliban fired rockets at one outpost. Days later, they attacked another.

“Every part of Afghanistan is important for us, but Chak district is more important than other areas,” Mujahid said. “It is close to Kabul and easy for our mujahideen to carry out attacks there.”

On this day, Dawood escorted his boss, Col. Badakhshani, and two visitors to the front line. The heavily armed convoy passed an outpost where six of Dawood’s men were killed this year and villages that once flew white Taliban flags. Fearing an ambush, Dawood posted men along the road.

“It’s very easy for the Taliban to plant IEDs,” Dawood explained, referring to roadside bombs. “And it’s very difficult for us to find them.”

Nature of war has changed

A half-hour later, the convoy pulled into Baba, a remote hilltop village ringed by mountains covered with patches of snow.

Badakhshani stepped out to inspect the terrain. He praised the soldiers, trying to boost their morale. As they walked, Dawood complained that his men have had no assistance from the national police.

“Everything is on our shoulders,” he told his boss.

“If I had 300 more men, I can push the Taliban out of Chak Valley,” Dawood said later.

U.S. commanders such as Anderson think that without a close partnership between the army and police, security will deteriorate next year. Also of concern is political interference by some influential Afghan officials who tend to view the nation’s security forces as their personal army.

“They’ve got to keep working intelligence-driven operations versus politically based operations,” Anderson told reporters recently. “They have to keep working their air support.”

Afghan commanders, though, have little faith in their nation’s ill-trained air force. Many welcomed President’s Obama’s announcement last month that expanded the U.S. military role after the drawdown. It allows American forces to engage in combat and provide air support if a serious militant threat emerges.

But Dawood and his superiors understand that the nature of their war has changed — and that American air support will be rare next year.

“It will be harder to fight the enemy,” Badakhshani said.

Winning over village elders

The two commanders spent more than an hour meeting with village elders. Winning their hearts and minds is vital to retaining control.

The village, like much of the valley, is dominated by Pashtuns, the ethnic group that most Taliban fighters belong to. In many villages, the Taliban runs a shadow government, delivering justice and taxing villagers. A propaganda council constantly condemns the Afghan government and its security forces.

No villagers interviewed dared to criticize the Taliban. Instead, they expressed concern about being trapped again in the middle of the conflict.

“We are scared of the Taliban government and the Afghan government,” said Mohammed Yusuf. “We’re tired of the fighting.”

Over a lunch of rice and meat, Badakhshani assured the elders that his forces would protect them. Dawood declared that his men would not storm into houses searching for Taliban spies or sympathizers.

The elders were unconvinced. Some feared that the Taliban would target them just for having lunch with the commanders.

“If the soldiers leave, it will be a disaster for us,” said Fazel Ahmad, a thick-bearded man who hosted the gathering.

Badakhshani also told the elders that the government would pave the main road and make fully operational a nearby dam that generates electricity.

But Dawood later worried that the promises would go unfulfilled. The Afghan government is nearly bankrupt.

“If the government doesn’t pave the road or fix the dam, then there will be no difference between the government and the Taliban,” he said as the convoy rolled past a large crater from a roadside bomb.

At the edge of a village lay a rusted Soviet tank, destroyed two generations ago. It was a reminder of the many times the Chak Valley has changed hands.