British Prime Minister David Cameron has made a surprise visit to Afghanistan and held talks with newly-inaugurated Afghan President Ashraf Ghani, as NATO troops end their long war against the Taliban.

Cameron arrived in Kabul on Friday on the unannounced visit after visiting an air base in Cyprus, used by British jets launching strikes against fighters from the Islamic State of Iraq and the Levant group.

Speaking at a joint press conference, Cameron outlined some of what he called Britain's accomplishments in Afghanistan: "We have been very clear about what we've been trying to achieve ... and that is to build an Afghanistan capable of looking after its own security without the need for a large number of foreign troops."

"It is good governance that kills terrorism and the real and pressing need is for this new national unity government to bring the country together". 

He added that Britain will always be "a strong partner and good friend" with Afghanistan.

Live Box 201491152731407786

The British army has wound down its presence in the volatile southern Afghan province of Helmand after years of heavy fighting in some of the areas where the Taliban has launched fresh offensives in recent weeks.

Britain still has 3,900 troops in the country as part of the NATO's International Security Assistance Force (ISAF), most of them at Camp Bastion in Kandahar province.

ISAF will complete its combat mission at the end of this year, with a follow-up "support" mission taking over in 2015 on training duties, assisting the Afghan army and police.

The British contribution to the follow-up mission will be to an army officers' training academy outside Kabul.

Ghani was sworn in on Monday after a fraud-tainted election that plunged Afghanistan into months of political deadlock.

In a US-brokered deal, Ghani signed a power-sharing agreement with his former poll rival Abdullah Abdullah, who was appointed to the new position of "chief executive".

The stability of the new "national unity government" is seen as essential for Afghanistan's future as the international military presence and aid funding declines.

Source: Agencies