A project to support the embattled Libyan government by training the country's fighters in the UK has been thrown into doubt following a series of alleged sex attacks.
Up to 2,000 soldiers had been due to undergo basic infantry and junior command training at Bassingbourn Barracks in Cambridgeshire as part of an agreement reached at last year's G8 summit.
But the Ministry of Defence (MoD) said it was reviewing whether Libyans could continue to train in the UK following "disciplinary issues", including five men being charged with sex offences against members of the British public.
The first batch of 300 soldiers had been due to end their stay at the end of the month but they will now return "in the coming days".
South Cambridgeshire MP Andrew Lansley, who had called on the MoD to terminate the contract with the Libyan government, said it was clear the initiative had not worked.
He added: "It is regrettable but necessary to accept that the programme has concluded here."
An MoD spokesman said there would now be a review of how best to train Libyan security forces - including whether further recruits should be trained in the UK.
He added: "The majority of recruits have responded positively to the training despite the ongoing political uncertainty in Libya, but there have been disciplinary issues.
"Training was initially expected to last until the end of November but we have agreed with the Libyan government that it is best for all involved to bring forward the training completion date.
"The recruits will be returning to Libya in the coming days.
"The UK remains committed to supporting the Libyan government as it works to establish stability and security across the country."
The agreement was part of a pledge to support Libya's effort to improve security following the overthrow of Colonel Gaddafi in 2011.
Since then the country has been in a state of flux with two rival governments, disparate tribes and Islamist militia embroiled in conflict.
The internationally recognised government has been forced to operate from the far eastern city of Tobruk after hostile forces took control of the capital Tripoli in July.
Disciplinary problems came to light after Libyan cadets Ibrahim Naji El Maarfi, 20, and Mohammed Abdalsalam, 27, appeared at Cambridge Magistrates' Court last week and admitted two counts of sexual assault. They are awaiting sentencing.
Khaled El Azibi, 18, has been charged with three counts of sexual assault linked to the same incident but has yet to enter a plea.
Last night, Moktar Ali Saad Mahmoud, 33, and Ibrahim Abogutila, 22, were charged with rape.
They appeared before the city's magistrates this morning where their case was adjourned for them to appear at Cambridge Crown Court next Tuesday. They were remanded in custody.
Shadow defence minister Ian Lucas said: "The training of Libyan soldiers was central to the UK Government's long-term security strategy for the region.
"Having been significantly delayed in the first instance, the UK-based training programme has now collapsed in disarray and scandal, and there are no plans to continue it elsewhere.
"The Defence Secretary (Michael Fallon) needs to explain how this has gone so badly wrong and urgently clarify the Government's strategy for helping to build a safe and stable Libya, including whether or not training Libyan soldiers is part of it."
Prime Minister David Cameron's official spokesman said: "We are now going to review how best the programme of training can be carried out. The group of soldiers that are currently in the UK will be returned to Libya in the coming days and we will then review how best it is done."
Asked whether it was possible that further groups of Libyans could come to the UK for training, the spokesman said: "The review will be on the basis of alternatives to training in this country."
He added: "What we have seen is that there has been some specific allegations with regard to alleged behaviour by one or more of the trainees and, more widely, what we have seen in Libya in recent weeks has been a deterioration in some of the political divisions in that country.
"There are some links to that effect as well. That's why it has been right to take the decision that we have."
Chairman of Bassingbourn Parish Council Peter Robinson said villagers living near the base would react to the Libyans' departure "with joy".
In a film clip on YouTube, Mr Robinson said: "The main problem has been the escapees and the fear that it's put into people.
"I have had ladies tell me they don't want to walk their dogs any more. There have been people who have come out of their house and have discovered Libyans hiding under their car.
"It doesn't give someone the feeling of safety and then following the allegations of what happened in Cambridge, it has made people's fears all the worse."
He added: "I think it could have been handled very differently. Everyone was prepared to give them the benefit of the doubt to start with, but following what's happened, I think the decision originally was bad and the security systems that they set up were virtually non-existent."