Small numbers of British troops could remain in Afghanistan after the withdrawal of the main force in 2014 to combat international terrorism.

As international leaders gathered in Chicago for a Nato summit focused strongly on the future of Afghanistan, a senior official disclosed there could be a continued fighting role for UK forces.

David Cameron has always insisted all British involvement in combat operations will end in 2014 as Afghan forces take responsibility for their own security.

He has said any future British commitment would be focused on training and mentoring the Afghans - such as the establishment of an officer training academy, dubbed "Sandhurst in the sand".

However a senior British official indicated the UK could retain a small presence - most probably special forces - to counter any attempt by al Qaida to re-establish a foothold in the country after most international troops have left.

"As we've said previously, British forces will not remain in a combat role in Afghanistan beyond 2014," the official said. "The majority of forces that remain in Afghanistan will be in a training and mentoring role, for example at the Afghan Officer National Training Academy. But I wouldn't rule out a small number of forces playing a counter terrorism role if needed. This would be in keeping with how we are working to protect ourselves from the counter terrorism threat emanating from other parts of the world, such as the Arabian Peninsula."

Ministers have always argued that the ultimate rationale for Britain's involvement in Afghanistan was to protect the UK from terrorism in the wake of the 9/11 attacks launched from training camps in the country.

Al Qaeda has since shifted the focus of its activities to countries such as Yemen and Somalia, but the absence of international troops in large numbers could tempt it to make a return to Afghanistan.

Much of the discussion in Chicago will centre on how the Afghans manage after 2014. The gathering will also consider the future role of the alliance itself as economic austerity forces governments to squeeze defence spending.

Cameron will argue forcefully that reduced spending on armed forces must not mean any lowering of Nato's ambition, and that it must continue to be prepared to tackle threats beyond its borders. He will reiterate the importance of Europe pulling its weight in the alliance - genuinely partnering the US rather than subcontracting its security to Washington.