President Obama awarded former Staff Sgt. Clinton Romesha the Medal of Honor for conspicuous gallantry for his leadership efforts in a 2009 attack by the Taliban on Combat Outpost Keating in Afghanistan. (The Washington Post)

President Obama awarded the Medal of Honor on Monday to a former Army staff sergeant for his courageous actions in defending a remote combat outpost in eastern Afghanistan from a 2009 insurgent attack that left eight Americans dead and 22 wounded.

Clinton L. Romesha — a section leader in a unit of the 4th Brigade Combat Team of the 4th Infantry Division during the attack on Oct. 3 on Combat Outpost Keating in the Kamdesh District of Nurestan province — became the fourth living recipient to be awarded the nation’s highest military honor for actions in Iraq or Afghanistan. He was wounded by shrapnel during the fierce 12-hour battle, in which he was credited with saving the lives of fellow soldiers pinned down by heavy fire from Afghan insurgents belonging to or allied with the Taliban.

The battle, one of America’s deadliest in the Afghan war, demonstrated the bravery and resourcefulness of Romesha and other U.S. troops in carrying out their mission. But it also illustrated the complexity of the Afghan insurgency. And it exposed the flaws of the military’s counterinsurgency strategy at the time and the inertia of higher-ups in dealing with an increasingly untenable situation in the mountainous area near the border with Pakistan.

Before awarding the medal to Romesha, Obama recognized family members of the eight American soldiers who died in the battle and the surviving members of the unit.

“These men were outnumbered, outgunned and almost overrun,” Obama said. He quoted one survivor as having said, “I’m surprised any of us made it out.”

Describing the U.S. outpost as “among the most remote” in the Afghan war, Obama acknowledged the controversy over its existence, calling it “tactically indefensible” and noting that American troops were asked to “defend the indefensible.”

“There are many lessons from COP Keating,” Obama said later. “One of them is that our troops should not — ever — be put in a position where they have to defend the indefensible.”

Recounting Romesha’s actions, Obama called the fighting that day “one of the most intense battles of the entire war in Afghanistan.”

After pulling back within the compound and preparing “to make one last stand,” which one soldier later likened to the Alamo, Romesha “decided to retake that camp,” Obama said.

Although wounded by shrapnel when a rocket-propelled grenade round struck a generator behind which he was taking cover, Romesha mounted a counterattack that ultimately succeeded in repelling the assault, Obama said.

“Clint gathered up his guys and they began to fight their way back — storming one building and then another, pushing the enemy back, having to actually shoot up at the enemy in the mountains above,” Obama said. “By now, most of the camp was on fire. Amid the flames and smoke, Clint stood in the doorway calling in airstrikes that shook the earth all around them.”

They eventually turned the tide, rescuing wounded comrades and retrieving the bodies of the fallen.

Calling Romesha “a pretty humble guy,” Obama recalled that when he called to inform Romesha of the award, “he said he was honored, but he also said, ‘It wasn’t just me out there. It was a team effort.’ ”

The attack came six days before the U.S. military was scheduled to close Combat Outpost Keating, which a Pentagon review later found should never have been established in the first place. In the months after the assault, the military tried to strike a deal with an insurgent leader known as Mullah Sadiq, the local commander of the radical Islamist Hezbi-i-Islami Gulbuddin militia, which had a tenuous and at times conflicting relationship with the Taliban. During the Soviet occupation of Afghanistan in the 1980s, Sadiq’s group was among the mujaheddin forces backed by the CIA. But in October 2009, U.S. commanders believe, some of Sadiq’s forces joined Taliban fighters in carrying out the attack on Keating.

Romesha (pronounced ROM-a-shay), now 31 and originally from Lake City, Calif., joined the Army in 1999 and served tours in Kosovo, South Korea and Iraq before deploying to Afghanistan. He left the Army in April 2011 and lives with his wife and three children in Minot, N.D., where he works as a field safety specialist in the oil industry.

At Combat Outpost Keating in 2009, he and about 50 other Americans, two NATO trainers from Latvia and an Afghan army unit manned a small, vulnerable compound that was surrounded by peaks of the Hindu Kush mountains, from which insurgents routinely fired down at the defenders. U.S. troops likened it to trying to fight from the bottom of a paper cup.

Military leaders came to realize that the post was too difficult to defend and the area too dangerous for provincial reconstruction teams. But plans to close Keating were delayed amid concerns about the message that such a retreat would send and its possible ripple effects on the political and security situation in Afghanistan.

When the Oct. 3 attack began at dawn, Romesha and other soldiers at Keating quickly realized that they were dealing with something far more serious than the usual sniping. More than 300 insurgents armed with B-10 recoilless rifles, rocket-propelled grenades, antiaircraft machine guns, mortars, sniper rifles and small arms attacked from every direction and quickly breached the compound.

Afghan troops soon abandoned their posts, leaving the Americans and Latvians pinned down.

“Every position was overwhelmed,” Romesha later explained, according to an account on the Army’s Web site. From the start, all the U.S. fighting positions were “pretty ineffective.”