In a Feb. 14, 2014 file photo, an Apache helicopter lands at Bagram Air Field, Afghanistan, as the sun sets behind the mountains.

For several days, Taliban fighters barricaded on a mountaintop lobbed rockets at the remote town of Sangar in the valley below. Residents fled while police holed up in their outposts and begged superiors for help.

At a sprawling base about 100 miles away, a contingent of Afghan army commandos prepared to board a helicopter to join the fight. But their commanders, worried that the insurgents would shoot down the aircraft, called the American military first.

U.S. Apache attack helicopters swept in and launched missiles at the Taliban posts, said Afghan officials involved in the late September incident. The firepower scattered the insurgents, clearing the way for the Afghan commandos to break the siege in the eastern province of Ghazni.

The U.S.-led coalition officially denies carrying out airstrikes in the battle 125 miles southwest of Kabul, saying international forces provided only aerial surveillance. Under former President Hamid Karzai, coalition airstrikes in populated areas were sharply restricted, although distressed Afghan commanders often requested help anyway.

In this case, several Afghan officials and military commanders say, an American air assault ensured that the district did not slip from government control in one of the largest clashes in months in a volatile province connecting Kabul with southern Afghanistan.

"The American helicopters hit two points high on the mountain where the Taliban were firing at us," said Gen. Haider Niqpai, commander of the Afghan army's 3rd Brigade, based in Ghazni. "That was the turning point."

Even as President Obama prepares to declare an end to U.S. combat in Afghanistan on Dec. 31, the accounts of the battle in Ghazni illustrate how crucial — and politically sensitive — the U.S. role remains in the fight against Taliban-led insurgents.

"In just a few days, our combat mission in Afghanistan will be over," Obama said in a Christmas Day address. "Our longest war will come to a responsible end."

The U.S. force in Afghanistan will shrink to about 10,800 in January under a pared-down mission focused on training and counter-terrorism. But under combat operations rules that Obama approved last month, U.S. commanders will still be authorized to conduct airstrikes to help Afghan troops who are suffering record casualties in ground skirmishes with a resilient Taliban.

Outgoing Defense Secretary Chuck Hagel said recently that U.S. forces would provide "limited combat enabler support" to Afghan troops starting in January.

The airstrikes would allow the smaller U.S. force to support their Afghan allies, who have minimal air capability, while exposing Americans to less danger than in ground fighting.

But airstrikes also carry the risk of additional civilian casualties, which stoke public anger, keeping the United States deeply enmeshed in a conflict that the White House promised to end.

In a farewell visit to Afghanistan in early December, Hagel insisted that Afghan forces had full responsibility for security and that all U.S. troops would withdraw by the end of 2016, as Obama has pledged. The broader U.S. combat policy "doesn't change any part of what the president's strategy is," Hagel said.

U.S. officials had initially signaled that airstrikes under the new mission would be restricted to protecting the remaining coalition forces, including an estimated 3,000 troops from other North Atlantic Treaty Organization countries. But the Afghan government under the new president, Ashraf Ghani, has signaled greater acceptance of American military engagement.

Afghan officials in Kabul are careful to say that commanders were ready to fight the Taliban without U.S. air power.

"It's up to the Afghan security forces and the young commanders in the field to demonstrate that leadership," said Zubair Massoud, an advisor to Ghani's national security council. "It's possible for them to do without airstrikes."

Airstrikes in Afghanistan have declined dramatically over two years as the coalition military presence has shrunk and Afghan forces have taken on most of the fighting. This year through November, U.S. warplanes carried out 2,237 strikes in Afghanistan, half the number from two years earlier, according to statistics from U.S. Air Forces Central Command.

But as fighting increased this summer, American forces carried out 437 strikes in August and 441 in September, the most in a two-month span since mid-2012.

The strikes are nonetheless of limited use against insurgents waging asymmetrical warfare. Despite nearly 20,000 U.S. missile launches since 2010, according to military statistics, a resurgent Taliban has retaken patches of territory this year that coalition commanders once deemed secure.

Afghanistan's air force remains a glaring weakness in the 352,000-strong army and police that the United States has spent $57 billion on building since 2002. Beset by low literacy rates, Afghanistan has struggled to train competent pilots. And U.S.-financed helicopters and fixed-wing planes often sit grounded for months because of maintenance problems.

The most common helicopter, the Russian-made Mi-17, has been controversial because Afghan pilots have had difficulty flying it and because of allegations of improprieties in the Pentagon's purchase of more than $1 billion worth of the aircraft from Moscow.

In 2013, the special inspector general for Afghanistan reconstruction chided the Pentagon for purchasing an additional 30 Mi-17 helicopters for the Afghan air force's counter-terrorism unit, because "the Afghans lack the capacity — in both personnel numbers and expertise — to operate and maintain the existing and planned fleets."

An independent assessment carried out in January for Congress by CNA, a research company, found that the Afghan air force's assault and surveillance capabilities were limited and that "none of its crews are capable of flying at night."

Afghan forces do almost all their fighting on the ground, which has meant more casualties. By early November, 4,634 Afghan soldiers and police had been killed in action this year, more than in any previous year, according to coalition statistics; analysts believe that that figure could have been underestimated.

The increased ground combat, often in populated areas, is also taking a devastating toll on Afghan civilians. The United Nations reported this month that 2014 has been the deadliest year for Afghan civilians since it began tracking the casualties in 2009, with deaths and injuries expected to top 10,000, a 19% increase from a year ago.

"The lack of air support is a big problem," said an Afghan intelligence official in Ghazni, who wasn't authorized to be quoted by name. "We can identify in certain areas 20 or 30 Taliban. But by the time we get there, they're gone."

The late September battle in Ajristan district "was not pretty," the official said. "Just when we were about to collapse, at the last minute they sent in two foreign helicopters."

Ajristan — an isolated valley ringed by jagged peaks, more than 10 hours by road from the provincial capital — had seen its main town, Sangar, fall to the Taliban twice in six years. Local officials say insurgents began their latest attack by swarming police outposts on the outskirts of Sangar, killing several officers and taking others hostage while setting fire to homes.

"It was a well-planned attack," said Mohammed Ali Ahmadi, deputy governor of Ghazni province. Taliban fighters from multiple provinces joined the assault, part of what Afghan officials say is an effort to establish beachheads in the provinces closest to Kabul.

A police contingent set off along the rocky road to Sangar, traveling the last stretch on foot, but the officers were ambushed as they approached. From their mountain bastions, insurgents lighted up homes in Sangar with rocket fire.

"They had us surrounded," said police Maj. Ramazan Ali, who participated in the battle.

Some local officials were so worried about losing Sangar that they told the news media outlandish stories about Islamic State-inspired attackers beheading civilians and raising black militant flags.

Analysts say that could have contributed to the decision to request coalition airstrikes. But police officials credit the Afghan commandos with driving the militants out of Sangar and helping reestablish control of the surrounding villages.

"In the short term, I'm happy that we as Afghan forces could stand up for ourselves," Ali said. "But in the long term, I worry about our shortcomings."

©2014 the Los Angeles Times

Visit the Los Angeles Times at www.latimes.com

Distributed by Tribune Content Agency, LLC

