In a decision that could set the stage for Ottawa resident Mohamed Harkat's eventual deportation to his native Algeria, a federal judge has ruled there are reasonable grounds to believe he remains a security threat.

"I find that Harkat has engaged in terrorism, that he is a danger to the security of Canada and that he is a member of the (Osama) Bin Laden Network," Federal Court Justice Simon Noel wrote in a decision released Thursday.

And, in a separate ruling, Justice Noel upheld the constitutionality of the federal security certificate system being used to remove Harkat from Canada.

The defence had argued that Canada's spy agency CSIS kept information that may have exonerated Harkat under wraps. But Noel said there was no evidence of abuse of process.

Matt Webber, one of Harkat's lawyers, said that his client would be appealing the ruling.

In his ruling on the security certificate -- a rarely used means for the Canadian government to detain and deport permanent residents or foreign nationals without revealing evidence against them -- Noel suggested Harkat has concealed the truth.

"He has surrounded himself in layers of clouds in which he does not let any light come through," Noel wrote.

"At times, his testimony was simply incoherent, implausible if not contradictory," the justice continued, suggesting the 42-year-old former gas bar attendant and pizza delivery man had not given the court a single credible statement.

Harkat was arrested on suspicion of being a sleeper agent for al Qaeda in December of 2002. Since then, the government has consistently suggested that the 42-year-old maintained ties with known terrorist networks since he arrived in Canada back in 1995.

"I find that although the danger associated to Mr. Harkat has diminished over time, he still poses a danger to Canada," Noel wrote.

The government alleges Harkat had ties with at least two high-profile al Qaeda operatives, both of whom are now deceased. He is also accused of operating a safehouse in Pakistan for the Islamist extremist group led by Saudi-born jihadist Ibn Khattab, and helping facilitate the movement of money and people for al Qaeda in Ottawa.

The judge also concluded that Harkat had visited Afghanistan, contrary to testimony, and has links to an Egyptian extremist group called Al Gamaa Al Islamiya.

The judge added that Harkat had contacts with Ahmed Said Khadr, the now-deceased dad of Omar Khadr.

However, details about allegations that Harkat either carried out, or was committed to carrying out actions on behalf of extremists have not been revealed in open court.

In March 2005, a court ruled that it was reasonable for the government to conclude Harkat was an al Qaeda terrorist. But that decision was overturned by the Supreme Court, on the grounds the security-certificate process was too secretive.

The government was subsequently ordered to revamp its security certificate legislation.

Harkat, who was held for more than three years before his release on bail in June 2006, steadfastly denies any involvement with terrorism and says he faces torture if sent back to Algeria.

Instead, he says he's nothing more than a refugee who fled his homeland and happened to spend five years working with an aid agency in Pakistan before coming to Canada on a false Saudi passport.

Harkat, who had a second national security certificate issued in his name in 2008, now lives under house arrest in Ottawa with his wife Sophie.

The ruling means Harkat is now under an automatic deportation order, leaving it to a federal immigration officer to assess whether or not he faces a significant risk of torture if returned to Algeria.

In Ottawa, CTV's Roger Smith said no matter what happens to Harkat, his movements will be tightly controlled for as long as he is here.

"Because of this decision he will remain under strict supervision for as long as he remains in Canada," Smith said, explaining that the terms of Harkat's bail include wearing a GPS monitoring device and weekly reporting to authorities.

Noel's ruling makes Harkat the first terrorism suspect to have his security certificate upheld since the law was updated two years ago.

Two others, Adil Charkaoui and Hassan Almrei, have seen their security certificates quashed. Both are now suing the government for millions in damages.

Harkat is expected to respond to Justice Noel's rulings in a press conference on Friday.

With files from The Canadian Press