But this year, another threat emerged: an intensified wave of attacks by Afghan security forces. In just the past two weeks, at least 9 Americans have been killed in such insider attacks. For the year to date, at least 40 NATO service members, most of them American, have been killed by either active members of the Afghan forces or attackers dressed in their uniforms — already outstripping the toll from all last year.

Those insider attacks have increased concerns about NATO’s ability to turn security operations over to Afghan forces by 2014, the deadline set by President Obama for withdrawing the remaining American forces. For families, the deaths have raised hard questions about whether the Pentagon is doing enough to protect its troops from their own allies.

Though Afghanistan is now considered the nation’s longest war, at 128 months and counting, the number of dead is fewer than half the total in the Iraq war, where more than 4,480 died in eight years. More active-duty and reserve soldiers killed themselves last year, 278, than died in combat in Afghanistan, 247.

None of that brings solace to the families of the dead. For the Buckleys, of Oceanside, N.Y., their son’s death so near the end of his tour, so late in the long war and possibly at the hand of a purported ally, was uniquely anguishing.

As Mrs. Buckley recounted things her son loved — basketball, girls, movies, the beach — bitterness choked her words.

“Our forces shouldn’t be there,” she said. “It should be over. It’s done. No more.”

A Unit Hit Hard

The Third Battalion, Fifth Marine Regiment out of Camp Pendleton, Calif., was emblematic of the surge. Sent into Sangin, Afghanistan’s opium-producing heartland, in 2010, the battalion faced a formidable enemy expert in the use of I.E.D.’s., losing 25 Marines in a seven-month tour, the second most of any American unit in the entire war, a Times analysis shows.

Mark Moyar, an independent national security analyst who has studied the battalion’s operations, said that the British who had preceded the Marines in Sangin, a district in Helmand, focused on economic development and political outreach to undermine the insurgency. But the Taliban also operated with near impunity in parts of the district, he said.