OTTAWA -- A Pakistani man was deprived of his right to challenge his detention in person before a judge, the Supreme Court said Friday, opening wider appeal options for migrants facing lengthy incarceration.

Although Tusif Ur Rehman Chhina was stripped of his refugee status and was sent back to Pakistan in 2017, the country's top court agreed to hear his case because it rarely gets to rule on the ancient legal recourse known as habeas corpus -- the right to have the validity of one's detention reviewed for whether it's lawful.

The principle is enshrined in the Charter of Rights and Freedoms, which means people held in custody by the state have a right appear before a provincial superior-court justice to argue over whether their detention is justified.

The high court ruled 6-1 in favour of Chhina, rejecting the government's argument that the system under which he was held, laid out in the Immigration and Refugee Protection Act (IRPA) was good enough because it offers a comprehensive and expert process by an independent, quasi-judicial board that provides a meaningful review. Also, decisions by the Immigration and Refugee Board can be challenged, in certain ways, to the Federal Court.

Not good enough, said a majority of the high court.

Justice Andromache Karakatsanis, writing for the majority, said the current scheme falls short in three ways.

"First, the onus in detention review under the IRPA is less advantageous to detainees than in habeas corpus proceedings. Second, the scope of review before the Federal Courts is narrower than that of a provincial superior court's consideration of a habeas corpus application," she wrote.

"Third, habeas corpus provides a more timely remedy than that afforded by judicial review."

The lone dissenter in the case, Justice Rosalie Abella, argued the current system works fine.

"In the absence of evidence that the 'complete, comprehensive and expert statutory scheme' does not provide for a review at least as broad and no less advantageous than habeas corpus," Abella wrote, "I see no reason to disturb the Court's jurisprudence by opening an alternative route, one that will lead to the forum shopping, inconsistent decision making, and multiplicity of proceedings" the court has worried about in other cases.

The federal government had argued that extending the right to direct hearings before judges to migrant detainees would create uncertainty in the legal processes involving these decisions.

Friday's ruling centres on Chhina, who was granted refugee protection in Canada in 2006 but was later detained after authorities learned he had a criminal record and after he had fled custody.

He failed in 12 attempts to the Immigration and Review Board to be released and was eventually deported.

Chhina applied for habeas corpus while in an Alberta maximum-security facility in May 2016.

His application was filed after his refugee status had been revoked in April 2013, and he was placed in immigration detention as a danger to the public and because he was considered unlikely to appear for his removal from Canada.

He was released from custody six months later because of delays related to his removal, and went missing again before he was re-arrested in November 2015.

He was eventually deported in late 2017.

"In this case, even without regard to this evidence, it was clear that the statutory scheme, including judicial review at the Federal Courts, is not as advantageous as habeas corpus given the nature of the challenge," wrote Karakatsanis.

"Although our legal system continues to evolve, habeas corpus 'remains as fundamental to our modern conception of liberty as it was in the days of King John' and any exceptions to its availability must be carefully limited."

Habeus corpus means "produce the body," and is rooted in 13th-century British law, which required that prisoners be brought before a court to ensure they hadn't perished in the squalid prisons of the day.