TORONTO -- A West African man who spent seven years in a maximum security prison awaiting deportation can pursue only part of his civil lawsuit against the federal government, an Ontario court has ruled.

The decision means that immigration adjudicators, who routinely kept Kashif Ali in custody based on evidence from Canada Border Service Agency, are off the hook. However, the federal government failed to persuade the court to strike the man's claim against the border agency pre-trial for malicious prosecution, intentional infliction of harm, and breach of his rights.

"I have been left unpersuaded by (Canada's) submissions," Superior Court Justice Shaun Nakatsuru said in his ruling. "I agree with Mr. Ali that these are novel issues of law and cannot be determined on a motion to strike."

Court records show Ali was born in Ghana to a Ghanaian father and Nigerian mother but his birth was apparently never registered. Neither Ghana nor Nigeria accept him as a citizen. Ali arrived in Canada in 1986 and made a refugee claim.

After convictions for mostly petty crimes in 1995, the government deemed him a danger to the public. Canada deported him in January 1996 to Ghana, where he was detained for 10 months before being returned to Canada.

Ali claims Canadian authorities prolonged his detention in Ghana as a pressure tactic.

"Mr. Ali has plead that Canada knowingly subjected him to harsh, cruel, and dangerous conditions in the Ghanaian jails and prolonged his detention there to induce Mr. Ali to provide information that the CBSA believed he was withholding," Nakatsuru said. "These are sufficient material facts to support the requirement that Canada brought this harm about in a calculated fashion."

Released on bail in Canada, the former Toronto taxi driver would be accused of committing further crimes, leading to his arrest on immigration grounds in February 2010.

During his subsequent seven-year incarceration, Ali had more than 80 detention reviews before the Immigration Division. At each, the border agency argued he should remain in custody on the grounds that he was not co-operating with his deportation and was withholding information.

He was finally freed at age 51 in April 2017 when an Ontario justice ruled his detention was a violation of his rights.

Ali maintains the agency misled the adjudicators, who kept him behind bars, about the prospects of his deportation and his ability to facilitate his removal.

His unproven lawsuit seeks millions for mental and physical problems caused by the detention. The suit alleges government wrongdoing and a breach of his constitutional rights given that Ottawa knew it could not deport him.

In its motion before Nakatsuru, Canada argued the claims against the adjudicators who ordered him detained should be struck as immune from a lawsuit. Nakatsuru agreed with the government on that part, saying the officials were essentially only doing their jobs based on the evidence they were given.

"I recognize that it is also alleged that the adjudicators upheld the CBSA's unlawful use of detention as a coercive tactic, but this is just a bald assertion," the judge said. "What is completely lacking is any material facts supporting the adjudicator's knowledge of this or the requisite intention by the adjudicators to aid the CBSA in this."