Updated 10:24 p.m. ET, 5/25/2014
(CNN) - President Barack Obama spent just over four hours in Afghanistan Sunday on an unannounced trip to visit with U.S. forces during the Memorial Day weekend. He thanked the troops for their service as the United States hands over responsibility to Afghan forces.
"Al Qaeda is on its heels in this part of the world, and that's because of you," Obama said.
He quickly added, "Everyone knows Afghanistan is still a very dangerous place."
The United States has been fighting in Afghanistan for more than 12 years, which is the U.S.'s longest war. "Last year marked a major milestone," the President said, as Afghan forces took increased responsibility for securing the country.
"For many of you, this will be your last tour in Afghanistan," Obama said to applause.
"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."
This was his fourth trip to the country, with his last being on May 1, 2012, when he made an address to Americans about U.S. involvement in Afghanistan.
Country music star Brad Paisley traveled aboard Air Force One with the President this weekend. He performed for some of the 32,000 Americans serving in Afghanistan at a major rally.
After the event, Obama went to a hospital to visit troops.
Air Force One left for Afghanistan late Saturday night and arrived at Bagram Airfield on Sunday morning Eastern time.
Also traveling with Obama was national security adviser Susan Rice and adviser John Podesta, whose son is currently serving in Afghanistan. Others aboard Air Force One included senior aide Dan Pfeiffer and deputy national security adviser Ben Rhodes.
Obama’s trip comes as his administration is facing criticism over how the Veterans Administration has handled prolonged wait times and other health care issues for veterans.
Speaking to reporters en route to Bagram, Rhodes said the VA scandal was not “a factor in the planning of this trip,” but said Obama would talk to veterans about support that troops and vets will have once they return home.
While Obama didn't address the scandal, he did praise veterans, promising to help members of the U.S. military transition into civilian life.
If you want to get something done, "hire a vet," he said, reiterating that taking care of U.S. veterans is Americans’ “sacred obligation.”
Obama did not meet with Afghan President Hamid Karzai or with Abdullah Abdullah or Ashraf Ghani, who are campaigning for a June 14 runoff election to succeed Karzai. Rhodes said Obama “didn’t want to get in the middle of election season.”
President Obama did, however, call President Karzai while at Bagram to praise him for the progress made by Afghan security forces and for the successful conduction of the country’s first-round elections. He also expressed support for recent reconciliation efforts with the Taliban.
The Obama administration is also still deciding whether any U.S. troops will remain in Afghanistan beyond 2014.
Obama plans to address foreign policy later this week in a speech at West Point, where he's set to lay out his vision for how the U.S. should apply force around the world.
CNN's Jim Acosta, Ashley Killough and Dana Davidsen contributed to this report.