President Obama greets service members at Bagram Air Base in Afghanistan

*Before President Obama concluded his surprise 6-hour trip to Afghanistan on Sunday, the Commander in Chief took time to speak to some of the US troops stationed there. (Scroll down for more photos.)

His bid to shore up faith in the struggle was aimed both at the troops who cheered him and Americans back home. And, he demanded accountability from Afghan authorities to make good on repeated promises to improve living conditions, rein in corruption and enforce the rule of law to prevent people from joining the insurgency.

“Your services are absolutely necessary, absolutely essential to America’s safety and security,” the president told a lively crowd of about 2,500 troops and civilians at Bagram Air Field north of Kabul. “Those folks back home are relying on you. We can’t forget why we’re here.”

It was Obama’s first trip as president to Afghanistan, where the number of U.S. troops killed has roughly doubled in the first three months of 2010 compared with the same period last year as Washington has added tens of thousands of additional soldiers to reverse the Taliban’s momentum.

“We did not choose this war,” Obama reminded the troops, recalling the Sept. 11, 2001, attacks and warning that al-Qaida was still using the region to plan terrorist strikes against the U.S. and its allies. “We are going to disrupt and dismantle, defeat and destroy al-Qaida and its extremist allies.”