In closing submissions, lawyer Johanne Doyon accused Canada's spy service of unethical tunnel vision in its 12-year quest to have Mohamed Mahjoub deported.
"We know now that there is a large part of the file that was based on (torture)," Doyon told Judge Edmond Blanchard.
The Canadian Security Intelligence Service, she said, did not have "sufficient morality" to exclude evidence against Mahjoub they knew was obtained from torture.
Mahjoub, a father of three, has been in prison or under house arrest in Toronto since he was first slapped with a national security certificate in 2000.
His lawyers are trying to have the case against him thrown out as an abuse of process.
Doyon said evidence obtained from torture "cannot be established as viable" and accused the government of willingly violating the Charter and subverting the judicial system for its own ends.
"This is not decent at all," she said. "The only conclusion is to quash the certificate."
Based in large part on secret evidence, the government insists Mahjoub was a ranking member of the Vanguards of Conquest, an Egyptian group linked to al-Qaida.
Mahjoub, 52, also worked on an agricultural project in Sudan run by al-Qaida leader Osama bin Laden in the early 1990s.
Doyon noted a series of problems with the government's case, including the fact that the spy agency destroyed the original recordings of interviews it did with Mahjoub, who came to Canada in 1995 and was granted refugee status.
All that's left of those interviews are summaries, which amount to "residual evidence of the evidence that was destroyed," she said.
"This should not be admitted by the court."
The government has not produced any independent evidence that Mahjoub ever committed, or would commit, terrorist acts, she said.
CSIS also made no attempts to investigate or verify information it was given by foreign intelligence services, and its case against Mahjoub, she insisted, was not based on anything credible.
She noted there was no evidence to show the bin Laden farm was anything other than a legitimate business, and accused the government of trying to convict Mahjoub based on people he might once have had contact with.
"This is guilty by association, which is something you should not allow or should prevent," she told the judge.
She also noted there was no definitive proof Mahjoub even belonged to the Vanguards of Conquest and accused the spy service of having "paranoid vision."
Over the years, CSIS has admitted listening in on calls between Mahjoub and his lawyers, and last year, government lawyers mistakenly took files belonging to his defence.
"I'm very frustrated with the Canadian government," Mahjoub said outside court.
His lawyers' closing submissions are expected to wrap up on Monday.
Mahjoub has staved off deportation to Egypt on the basis he would likely be tortured there.
Two other Muslim men are also fighting their national security certificates: Egyptian Mahmoud Jaballah and Algerian Mohamed Harkat, whose case is pending before the Supreme Court of Canada.