During a surprise visit to Kabul, Prime Minister David Cameron has promised that Britain will always be "a strong partner and a good friend" to the country.
On October 3, Cameron became the first Western leader to meet with President Ashraf Ghani Ahmadzai, who was sworn into office this week following months of political turmoil.
Holding a joint press conference with Ghani, Cameron said Britain is committed to helping Afghans build a "more secure, stable, and prosperous" future.
He also called on the new Afghan national unity government to "bring the country together in a way that can deliver noncorrupt, good governance to the whole of Afghanistan."
Ghani took office on September 29 after coming to a power-sharing agreement with presidential rival Abdullah Abdullah, who was sworn in as chief executive with powers similar to that of prime minister.
Cameron lauded both men, saying they put national interests ahead of "personal power."
Ghani said the political unity that had been forged with the new government was "essential to solve the problems of Afghanistan."
He also paid tribute to all foreign soldiers who died in combat in Afghanistan, and said British troops had stood "shoulder to shoulder" with Afghanistan.
Upon arriving in Afghanistan, Cameron, who was to visit British troops in Helmand Province, paid tribute to the 453 British troops who have died while serving in in the country, as well as those who have been injured.
After the United States, Britain has been the second-largest contributor to the international military coalition in Afghanistan.
British combat troops are due to leave the country by the end of the year after a 13-year campaign.
This week, Ghani's administration signed a long-delayed security deal allowing nearly 10,000 U.S. troops to remain in Afghanistan after the international combat mission ends on December 31.
A similar agreement was signed with NATO, spelling out terms to allow up to 5,000 additional international troops -- mostly from Britain, Germany, Italy, and Turkey -- to stay in Afghanistan in a noncombat role after 2014.
Britain has also been one of the largest financial donors to the Afghan government.
Cameron pledged $287 million a year until 2017 to "sustain the major progress" the country had made on education, health, and other public services.
He also said he and Ghani would jointly host a conference on future aid to Afghanistan in London in November.
Earlier, Britain's prime minister visited a British air base in Cyprus from where jets are launching strikes against Islamic State militants in Iraq.
Speaking in Kabul, Cameron said, "The work of defeating Islamist extremist terror goes on elsewhere in the world."
"And because this threatens us at home, we must continue to play our part," he added.
Cameron later visited British troops in Helmand Province, telling them that they face the "struggle of our generation" against Islamic extremists around the world.
The prime minister also told the soldiers at Camp Bastion that their work would continue elsewhere in the world, but "maybe not in the same way" as in Afghanistan.