Moloud Sihali, previously cleared of taking part in an alleged poison plot, had faced return to his home country.
The Special Immigration Appeals Commission said ministers could appeal their decision - but also ruled three other Algerians should be deported.
Mr Sihali, 30, was cleared in 2005 by a jury at the Old Bailey of taking part in an alleged terrorist conspiracy to spread the poison ricin in London.
He was later placed under restrictive bail conditions amounting to a form of house arrest while he mounted legal challenges to the Home Office's attempts to deport him.
In a judgement at SIAC, Mr Justice Mitting ruled Mr Sihali was not a threat to national security and should not be deported under a special arrangement between the UK and Algeria for terrorist suspects.
Mr Justice Mitting relaxed the bail conditions while giving the Home Office 10 days to appeal.
Three other Algerians lost appeals against deportation. The first man, known only as U, is already appealing. Lawyers for the other men, W and Z, are considering whether there are separate grounds for an appeal.
Previously, Mr Sihali had told the BBC he had no connections to terrorism and had unfairly been labelled "suspicious".
"I do not know what will happen to me if I go back to Algeria," he said. "Will I be prosecuted? Will I be persecuted? That is what I fear."
Home Office disappointed
Home Office minister Tony McNulty said he welcomed the court's approval for the deportation of three of the four men.
"The court has once again upheld our view that it is safe to deport such individuals to Algeria and accepted that diplomatic assurances from Algeria are valid and can be relied upon to ensure a person who threatens the UK can be deported safely," he said.
"We are disappointed, however, that the SIAC has determined that Sihali does not pose a threat to our national security.
"The government's highest priority is to protect public.
We will be examining the determination closely to establish whether we have an avenue to appeal to the Court of Appeal and, if so, we will seek to overturn the decision."
Massoud Shadjareh, of the Islamic Human Rights Commission, a campaign group, welcomed the ruling on Mr Sihali, saying SIAC was upholding due process in the UK.
"We cannot combat terrorism if we lose our basic values," said Mr Shadjareh.
The government has a "memorandum of understanding" on returning terrorism suspects to Libya, Syria and Jordan. A different diplomatic agreement is in place with Algeria covering the treatment of returnees.
In April, Siac blocked the deportation of terrorism suspects to Libya on human rights grounds, a major blow to the policy.
Critics of the government's policy say none of the deals guarantee the safety of those returned.