KABUL, Afghanistan (AP) — Britain's Prime Minister David Cameron on Friday pledged support for Afghanistan's newly sworn-in president and the country's new unity government, saying during a surprise visit to Kabul that Britain is committed to helping Afghans build a more secure and prosperous future.
Cameron was the first of world leaders to meet Ashraf Ghani Ahmadzai since his inauguration on Monday. The two had a meeting in Kabul on Friday morning and later held a joint press conference.
"Britain has paid a heavy price for helping to bring stability to this country," Cameron said, paying tribute to the 453 British servicemen and women who died while serving in Afghanistan.
"An Afghanistan free from al-Qaida is in our national interest — as well as Afghanistan's," he said. "And now, 13 long years later, Afghanistan can — and must — deliver its own security."
But, "we are not leaving this country alone," he added. "In Britain you will always have a strong partner and a friend."
Cameron arrived a day after visiting British pilots in Cyprus who are taking part in airstrikes on Islamic State group targets in Iraq. British warplanes have been conducting combat missions over Iraq since Saturday, after Britain joined the U.S.-led coalition of nations that are launching airstrikes against the militants.
"The work of defeating Islamist extremist terror goes on elsewhere in the world," Cameron said in Kabul. "And because this threatens us at home, we must continue to play our part."
Ghani Ahmadzai thanked the British for their sacrifices in Afghanistan, especially the families who lost loved ones in the war. "They stood shoulder to shoulder with us and we will remember," he said.
Ghani Ahmadzai's inauguration this week marked the start of a new era for his country, with a national unity government poised to confront a resilient Taliban insurgency.
A day after he was sworn in, his administration signed a security agreement allowing the United States to keep about 9,800 troops in the country to train and assist Afghan national security forces. A separate agreement was signed with NATO, outlining parameters for 4,000 to 5,000 additional international troops — mostly from Britain, Germany, Italy and Turkey — to stay in a noncombat role after NATO's combat mission ends on Dec. 31.
Former President Hamid Karzai had refused to approve the deal, and the results of a June presidential runoff to replace Karzai took months to resolve, finally coming to a conclusion with Ghani Ahmadzai's swearing-in and the establishment of a national unity government.
Ghani Ahmadzai's former rival for the presidency, Abdullah Abdullah, was appointed the country's new chief executive, a post akin to prime minister.
Cameron lauded both Afghan men, saying they put national interests ahead of "personal power" when they struck a power-sharing deal. "I look forward to working with both of you in the years ahead," he said.
Ghani Ahmadzai also praised his former rival, saying the two of them "have managed a first, which is really rare in the Muslim world — a democratic transfer of authority, not power."
Cameron also added a warning to the insurgents. "If the Taliban want to secure a role in the future of Afghanistan, then they must accept that they have to give up violence and engage in the political process," he said.
Later Friday, Cameron met with British troops at Camp Bastion in southern Helmand province, where he told soldiers who are to leave by the end of the year that Britain was "incredibly proud of you, incredibly grateful for everything you've done."
At the peak of the 13-year deployment there were almost 10,000 British troops in Afghanistan. About 3,000 remain, and all British combat forces are due to withdraw within weeks.
Cameron linked the battle against the Taliban and al-Qaida to the fight to stop militants such as the Islamic State group in Syria and Iraq and Boko Haram in Nigeria.
"This struggle against Islamist extremist terrorism, this is the struggle of our generation," he said.
Earlier in Kabul, he insisted there was no prospect of Britain going back to fight in Afghanistan.
"We are not going to send combat troops back to Afghanistan, because we have trained up an effective Afghan army and Afghan police force. It has been hard, patient work," he said.
But more than a decade after U.S. forces helped topple the Taliban in the wake of the Sept. 11 attacks, Afghanistan is still at war with the Islamic militant group, which regularly carries out attacks, mainly targeting security forces.
Only this week, Taliban suicide bombers staged attacks on Afghan forces in Kabul, killing at least 10 soldiers. Even with residual foreign forces in the country, there remain serious questions about the ability of the Afghan troops to take on the militants on their own.
Britain is one of the largest financial donors to the Afghan government and Cameron said he and Ghani Ahmadzai would jointly host a conference on future aid to Afghanistan in November in London.
In addition, Cameron pledged 178 million pounds ($287 million) a year until 2017 to support education, health and other public services in Afghanistan.
Associated Press writers Bob Barr and Jill Lawless in London contributed to this report.