U.S. President Barack Obama has left Afghanistan after a 4-hour surprise visit to see American troops during the Memorial Day holiday weekend.

Speaking late Sunday at Bagram Airfield, the president told troops he is thankful for their service. He called them "real heroes." He also pledged to bring a “responsible end” to America’s longest war. He promised to announce “fairly shortly” how many U.S. troops will remain in the country after the current combat mission is concluded at end of this year.

Memorial Day is a time when Americans honor the country's war dead.

Obama said they are completing the U.S. mission in Afghanistan by decimating al-Qaida leaders in the tribal regions, reversing the Taliban's momentum and protecting lives back home by preventing attacks from the region.

He also said he hopes a U.S.-Afghan security agreement will be signed once a new Afghan president is sworn in.

Before leaving Afghanistan, Obama called President Hamid Karzai to praise the progress being made by security forces and the successful first round of presidential elections, and to express support for an Afghan-led reconciliation process with the Taliban. The call lasted 15 to 20 minutes according to a senior administration official.

International combat troops are set to complete their withdrawal from Afghanistan by the end of this year. Some forces could remain in the country after December 2014 in a training and advisory role, if Afghan leaders approve the bilateral security agreement.

Country music star Brad Paisley kicked off the president's rally with a performance for some of the 32,000 Americans serving in Afghanistan. Paisley traveled to Bagram Airfield with the president.

Path forward

Obama said his administration would likely announce soon how many troops the United States will keep in the country, as it winds down its presence after nearly 13 years of war.
“For many of you, this will be your last tour in Afghanistan, and by the end of this year the transition will be complete and Afghans will take full responsibility for their security and our combat mission will be over. America’s war in Afghanistan will come to a responsible end,” said the president.
Obama defended his military drawdown plans, but said a smaller American military presence in Afghanistan is needed to preserve gains the country has made over the past decade in areas such as education, health, politics and security. He praised the U.S. military for playing a central role in the progress Afghans have made over the past decade.  
“Think about last month’s [presidential] election. Despite all the threats from the Taliban, the Afghan people refused to be terrorized," said Obama. "They registered to vote. Afghan security forces secured thousands of polling places. Then millions of Afghans lined up to cast their ballot. And next month’s run-off [election] will be another step toward the first democratic transfer of power in the history of this nation.”
'Passive' policy criticized

The trip comes as Obama is being hit by criticism at home that his handling of foreign policy has been too passive in dealing with crises from Syria to Ukraine and Russia.

U.S. President Barack Obama greets U.S. Ambassador
U.S. President Barack Obama greets U.S. Ambassador to Afghanistan James Cunningham (C) and Gen. Joseph Dunfore, Commander of ISAF and U.S. Forces Afghanistan, during a surprise visit to the troops at Bagram Air Field, Kabul, Afghanistan, May 25, 2014.

He is to respond to the criticism in a speech on Wednesday at the U.S. Military Academy at West Point.
Obama also delivered remarks to troops at Bagram, getting hollers from the crowd as he told them, “I'm here on a single mission and that is to thank you for your extraordinary service.”
The president said, "Of all the honors I have as serving as president, nothing matches serving as your commander in chief. But I’m also here representing 300 million Americans who say thank you as well."
"When it comes to supporting you and your families, the American people stand united. We support you. We are proud of you. We stand in awe of your service," he said in a news conference monitored by VOA.
The president will not make a hospital visit at Ramstein air base in Germany on his return trip, as had been reported. It is a refueling stop only, and was never planned to be a hospital visit
Criticism leveled at administration

His trip was bound to be seen by some critics as an attempt to redeem himself in the eyes of military veterans who are alarmed at allegations that government-run medical facilities in the United States have not provided timely care for veterans.
At Bagram, Obama was briefed by Army Gen. Joseph Dunford, who heads U.S. and NATO forces in Afghanistan, and U.S. Ambassador to Afghanistan James Cunningham.
Obama left Washington under cover of darkness on Saturday night and flew for more than 13 hours to arrive at Bagram on Sunday night local time.
He said the war had reached a pivotal point, with Afghan forces assuming primary responsibility for their country's security. By 2015, many of the 32,800 American forces now in Afghanistan will depart.
“For many of you, this will be your last tour in Afghanistan,” Obama said as hundreds of U.S. troops inside an airplane hangar erupted in applause.
“America's war in Afghanistan will come to a responsible end,” he said.
Some information for this report was provided by VOA's Ayaz Gul in Islamabad, AP, AFP and Reuters.