KABUL, Afghanistan -- The last time President Barack Obama visited Afghanistan, he came to sign a strategic partnership agreement with President Hamid Karzai.
But that was two years ago. When Mr. Obama returned to Afghanistan on Sunday, conspicuously absent from the agenda was a meeting with Mr. Karzai, who has staunchly opposed an enduring American presence in this country.
The trip to Afghanistan was unannounced, and Mr. Obama slipped out of the White House secretly Saturday evening. He arrived a day ahead of Memorial Day under the cover of darkness at Bagram Air Base, the sprawling American encampment north of Kabul, accompanied by the country music singer Brad Paisley, who performed for about an hour before the president spoke to troops.
Although Mr. Obama did not meet with Mr. Karzai, who is to leave office in the coming months, he vowed that he would work with whoever wins the presidential runoff scheduled for June 14: either Abdullah Abdullah or Ashraf Ghani Ahmadzai.
White House officials said that the trip, Mr. Obama's fourth to Afghanistan since taking office, was intended strictly as a visit with troops and that they wanted to avoid any appearance of trying to sway the Afghan political process.
They said U.S. officials offered Mr. Karzai the opportunity to join Mr. Obama at Bagram, but they were not surprised when the Afghan leader turned them down. A statement from Mr. Karzai's office was terse about the invitation: "The president of Afghanistan said that he was ready to warmly welcome the president of the United States in accordance with Afghan traditions," it said, "but had no intention of meeting him at Bagram."
But officials said Mr. Obama did talk by phone to Mr. Karzai for 15 to 20 minutes. They said he praised Mr. Karzai for progress being made by the Afghan security forces and for the recent presidential voting in the country.
The call was only their second conversation in nearly a year. The first one came in February, when Mr. Karzai called Mr. Obama to say that he would not be signing a long-term security deal with the United States.
Mr. Obama, in his remarks to troops Sunday, made it clear that he still wanted the deal signed, allowing the United States to keep a small military force in Afghanistan beyond 2014. His comments indicated that he may have ruled out the idea of a complete withdrawal of U.S. forces at the end of this year, a move that administration officials had repeatedly threatened was possible at difficult points in the negotiations over the security deal.
White House officials said there was no connection between Mr. Obama's trip, which they said was planned months ago, and the furor over misconduct at veterans' hospitals in the United States. But the visit will provide the president a symbolic military backdrop as his administration tries to fight accusations of mismanagement back home.
Mr. Obama did not make any major policy announcements in his remarks to the troops. He is expected to wait to offer his latest foreign policy and national security vision during a speech that he is scheduled to give at the U.S. Military Academy graduation Wednesday. In 2009, he used a similar setting at West Point to announce a decision to add more troops to the effort in Afghanistan, pushing the total U.S. presence there past 100,000.
The total number of U.S. troops in Afghanistan is now down to around 32,000, and U.S. officials hope to leave a far smaller contingent after 2014 to continue training Afghan forces and targeting the remnants of al-Qaida. Officials say the administration is still deciding how large the force will be.
Although Mr. Karzai has refused to sign the agreement for such a force to remain, both of the presidential candidates have indicated that they would sign the agreement upon taking office.