Five Libyan terrorist suspects currently held in prison in the UK are to be released on bail.
An agreement has been signed with Libya's Colonel Gaddafi
The five were due to be deported to Libya under an agreement signed by the UK and Libyan governments.
But a major ruling halted the deportations after judges decided the men's human rights were at risk.
Two of the men argued in court they could be jailed and tortured if sent home, despite a special deal between the UK and Libya.
The two men, held in Long Lartin prison, in Worcestershire, have been granted bail in principle, with restrictive terms to be finalised.
In the first test of the case, the Special Immigration Appeals Commission (Siac) said DD and AS could not be sent back to Libya.
The Home Office said it had opposed bail in all the cases involving Libyans, and that the decision to grant it had been a matter for Siac.
"We believe these individuals should continue to be detained - particularly since Siac has agreed that at least two of these individuals are a threat to the national security of the UK," said a statement.
The Home Office asked for strict bail conditions to be imposed. Ministers are also appealing the ruling.
Under international human rights law, the UK does not deport people to regimes where they may face persecution or torture.
But in October 2005, the government signed a historic deal with Libya, under which Colonel Gaddafi's government pledged not to mistreat anyone deported to Tripoli from the UK.
Similar memorandums of understanding have been signed with Jordan and Lebanon. A different diplomatic agreement is in place with Algeria covering the treatment of returnees.
In evidence placed before the Special Immigration Appeals Commission, the security services said the men posed a real danger to the UK because of their alleged links to terrorist organisations and networks.
One of the two men was tried in his absence in Italy for allegedly being part of a cell of Islamist extremists planning an attack in Europe.