Media playback is unsupported on your device Media caption Under international rules, detainees can normally be held for 96 hours

Up to 90 Afghans held at Camp Bastion are set to be returned to the Afghan authorities, the Ministry of Defence has said, after their lawyers argued that their detention could be unlawful.

Eight of the men said they had been held for up to 14 months without charge, according to their legal team.

Defence Secretary Philip Hammond had told the BBC that releasing them could endanger British troops.

But later the MoD said it had now found a "safe route" for their return.

The move came after the BBC was shown documents detailing how 85 suspected insurgents were being held at Camp Bastion, the main British base in Afghanistan.

The defence secretary later confirmed British forces were holding 80 to 90 detainees.

'Exceptional circumstances'

UK lawyers acting for eight of the men being detained said their clients were arrested by British soldiers in raids in villages in Helmand and Kandahar provinces, and have been held for between eight and 14 months without charge.

Media playback is unsupported on your device Media caption Philip Hammond: "We would like nothing more than to be able to hand these people over"

Mr Hammond told BBC Radio 4's Today programme: "We would like nothing more than to be able to hand these people over to the Afghan authorities".

There has been a bar on detainees being transferred to Afghan authorities since last November because of allegations that detainees were being abused.

Mr Hammond said the UK government has been working with its Afghan counterparts to find a safe way to resume transfers of detainees to the Afghan judicial system.

Later on Wednesday MoD officials said "once the policy and legal obligations have been met, direction will be given to restart transfers".

Suspects in Afghanistan are normally allowed to be detained by British forces for 96 hours.

Analysis British soldiers in Helmand will have welcomed the comments by Defence Secretary Philip Hammond on the BBC today that the only alternative to holding prisoners was to "release them onto the battlefield". They face a dilemma. No prisoners have been handed over to Afghan custody since Britain was taken to court by lawyers for a farmer who claimed he had been tortured in an Afghan jail after being arrested by British soldiers. When it emerged last November that Britain was holding Afghan prisoners it led to a strong reaction from President Karzai, who wants all detainees in Afghanistan to be held in Afghan facilities. US delay in handing over Bagram prison to Afghan control soured relations between the two countries. Once that handover had been completed in March, Britain became more exposed because of its decision to continue to hold prisoners. Australian forces have also stopped handing over detainees because of concern about torture. Who are the Afghan detainees?

However, in "exceptional circumstances" to gather critical intelligence, for example - they can hold them for longer.

Parliament had been informed and updated about the "temporary holding facility" at Camp Bastion, but the number of detainees currently being held there had not been known until now.

General Zahir Azimi, a spokesman for the Afghan Ministry of Defence, said the detentions were illegal and "inhuman".

"The prisoners must be handed over to the Afghan authorities," he said. "After their handover to us, they will be dealt with according to our judicial laws, and the agreements reached with the international community."

Dr Dotfar Spanta, national security adviser to the Afghan president, told the BBC Afghan Service that, after an exchange of letters with British officials, the resumption of detainee transfers had been resolved as far as his government was concerned.

He said they were waiting for a final response from the UK.

But lawyers for the men told the BBC they would want to scrutinise any transfers to the Afghan authorities carefully and may go to court to try to stop them.

'Perfect legal storm'

"The UK could have trained the Afghan authorities to detain people lawfully with proper standards and making sure they are treated humanely," Phil Shiner, of Public Interest Lawyers, told the BBC.

"They could have then monitored that, including with ad hoc inspections, to make sure the Afghans were obeying the law. They have chosen not to do so."

He said the UK was acting in an "entirely unconstitutional" way.

The BBC's legal affairs correspondent Clive Coleman said the government was in a bind about what to do with suspected insurgents.

A senior government lawyer, James Eadie QC, described the situation as a "perfect legal storm".

Media playback is unsupported on your device Media caption General Zahir Azimi, Afghan Ministry of Defence: "This is against Afghan law. It is also inhuman"

Lawyers for the eight men launched habeas corpus applications at the High Court in London on 18 April, with a full hearing due in late July.

Habeas corpus, in this context, argues for the right to be brought before a court to determine whether their detainment is lawful or not.

One of the prisoners is believed to be a teenager; the other a 20-year-old father. The pair, whose family say they were arrested in the spring last year, appear to have been held the longest.

Legal papers state their interrogation ended "many months ago", but their families only established where the men were being held with the help of the International Committee of the Red Cross.

Dan Squires, a barrister for the older man, told the High Court: "He has not been granted access to a lawyer nor brought before a court.

Nato guidelines on detention: British forces operate in Afghanistan as part of the Nato-led International Security Assistance Force (Isaf)

They are allowed to hold suspects for up to 96 hours before they are released or transferred to Afghan authorities

This can be extended in "exceptional circumstances" where it is necessary to gather intelligence from the detainee to protect British soldiers and local people

But there has been a bar on detainees being transferred to Afghan authorities since last November because of allegations that detainees were being abused

"He does not know how long he is to remain detained or for what purpose. He has asked whether he will be transferred to Afghan authorities but had been told they do not consider that he has committed any criminal offence and so do not want to receive him."

Mr Shiner said Mr Hammond had until last week refused to allow the detainees access to legal representation but had now granted lawyers an hour-long telephone call with two of the Afghans on Wednesday.

The defence secretary was keen to point out the Afghans' case was being brought "at the expense, of course, of the British taxpayer, because Mr Shiner's actions are funded by the legal aid system".

Mr Hammond added: "They are asking the court to release these people to turn them back to the battlefield so they can carry on with the activities for which they were detained in the first place - putting British troops and other Isaf lives at risk."