United States President Barack Obama has spent fewer than six hours in Afghanistan, on his first visit to the country since taking office.
Meeting Afghan President Hamid Karzai in Kabul, Mr Obama said he was inviting him to the US in May for talks, the BBC reports.
Mr Obama said he wanted to see progress continue on Afghan efforts to tackle corruption and drug-trafficking.
In a joint news conference, Mr Karzai thanked Mr Obama for US support and said he hoped the partnership would continue.
The BBC reports that for security reasons Mr Obama's trip was not announced beforehand, and Mr Karzai was given just an hour's notice.
At Bagram air base near the capital Kabul, Mr Obama told American troops that they are there to help Afghans to forge a "hard-won peace".
The president thanked the troops for their service, saying they would prevail against their enemies and were there to "keep America safe and secure".
Shortly after his speech to the troops, Mr Obama, who is travelling on his Air Force One jet, left the country.
In December, Mr Obama ordered the deployment of an extra 30,000 US troops to Afghanistan. Only a few thousand of the extra forces have arrived so far.
American troops are leading a massive military operation to push Taliban militants from their stronghold in the south of the country.