The UK is in talks with the Taliban to ensure Britons can safely leave Afghanistan, the government has said.

Its special representative for Afghan transition, Simon Gass, has met senior members of the hardline Islamist group in Doha, Qatar.

They also discussed safe passage for Afghans who have worked with the UK over the last 20 years.

Please use Chrome browser for a more accessible video player

Taliban fighters have fired shots into the sky in celebration as the final US troops left Afghanistan, ending 20 years of war.

A Downing Street spokesperson said: “The prime minister’s special representative for Afghan transition, Simon Gass, has travelled to Doha and is meeting with senior Taliban representatives to underline the importance of safe passage out of Afghanistan for British nationals, and those Afghans who have worked with us over the past 20 years.”

It comes as Foreign Secretary Dominic Raab admitted it will be a “challenge” for Britons left in Afghanistan to find a route to the UK.

He told Sky News the number of Britons who had not been flown out as part of the now-finished UK evacuation was in the “low hundreds”.

Mr Raab acknowledged it was “unclear” when the airport in Afghanistan’s capital, Kabul, would operate again and advised those who still sought to leave the country to find a route to the UK via neighbouring countries.

More on Afghanistan

More than 17,000 British nationals, Afghans who worked with the UK and other vulnerable people have been evacuated from the country since April, the foreign secretary said.

Of the UK nationals remaining in Afghanistan, Mr Raab said: “Most of those are difficult cases where it’s not clear around eligibility because they’re undocumented.

“We’ve now put in place the arrangements with third countries, or we’re putting them in place.

“I’ve spoken to some of the key third countries, so have other ministers, to make sure we can have a workable route through for those outstanding cases.”

Asked whether his advice for those UK nationals still in Afghanistan would be for them to head across one of the country’s borders, Mr Raab added: “It depends if they are eligible or not and, of course, we’re in contact with them to be able to establish that.

“That’s made more difficult because we don’t have the base at the airport.

“Certainly if they’re eligible British nationals, there are embassies in those third countries – whether it’s Pakistan or one of the stans.”