BAGRAM AIRFIELD, Afghanistan -- President Barack Obama surprised nearly 3,500 servicemembers gathered in a large aircraft hangar at Bagram Airfield late Friday night. The commander in chief, casually dressed, made his entrance around 10:30 p.m., and walked across the stage to the podium to a loud greeting from servicemembers, after being introduced by International Security Assistance Force Commander Gen. David Petraeus.

"It's great to be back," said Obama. "And I apologize for keeping you guys up late, coming on such short notice. But I wanted to make sure that I could spend a little time this holiday with the men and women of the finest fighting force that the world has ever known, and that's all of you."

The president traveled nearly 13 hours to personally thank military personnel and civilians for their sacrifices and service.

"I know it's not easy for all of you to be away from home, especially during the holidays," he said. "And I know it's hard on your families. They've got an empty seat at the dinner table."

"As President of the United States, I have no greater responsibility than keeping the American people secure," Obama continued. "I could not meet that responsibility, we could not protect the American people, we could not enjoy the blessings of our liberty without the extraordinary service that each and every one of you performs each and every day."

The president thanked the servicemembers on behalf of, not only himself, but on behalf of his family and more than 300 million Americans. He made a special point to express his gratitude for military families for all their support and sacrifices.

"We're going to spare no effort to make sure that your families have the support that they deserve as well," he pledged.

President Obama shared some good news when he announced his plans to spare servicemembers from future pay freezes.

"You may have noticed that during these tough budget times, I took the step of freezing pay for our federal workforce. But because of the service that you rendered, all who wear the uniform of the United States of America are exempt from that action."

A year ago, Obama authorized a surge of an additional 30,000 troops in Afghanistan. Those troops are now in place and are making progress, he said.

"And because of the service of the men and women of the United States military, because of the progress you're making, we look forward to a new phase next year, the beginning of a transition to Afghan responsibility," he said.

"As we do, we continue to forge a partnership with the Afghan people for the long term. And we will never let this country serve as a safe haven for terrorists who would attack the United States of America again. We said we were going to break the Taliban's momentum, and that's what you're doing."

"You're going on the offense, tired of playing defense, targeting their leaders, pushing them out of their strongholds," he said. "Today we can be proud that there are fewer areas under Taliban control and more Afghans have a chance to build a more hopeful future."

Before his visit with the large gathering of Soldiers, Airmen, Sailors, Marines, and even Coast Guardsmen, Obama visited with injured personnel at a hospital here, and awarded five Purple Hearts. He also spent time with a platoon that lost six members when an Afghan Police Officer opened fire at a firing range in Nangarhar Province. That incident is under investigation.

A face-to-face visit between Obama and Afghan President Hamid Karzai was originally planned, but travel to the presidential palace in Kabul which is about 30 miles south of BAF had to be canceled due to strong winds. The two heads-of-state spoke by telephone for about 15 minutes, reaffirming shared support for the gradual handing over of security to Afghan forces beginning in 2011.