TORONTO -- A Canadian appeals court on Thursday upheld a Canada-U.S. agreement to turn back asylum seekers, overturning a lower court ruling, siding with the federal government and setting up a possible Supreme Court showdown.

The Canadian government had launched an appeal defending the agreement and, by association, U.S. immigration detention practices. Canada had argued the pact was necessary to manage its border with the United States.

At issue was whether the Safe Third Country Agreement (STCA), a pact signed in 2002 and under which asylum seekers trying to cross between Canada and the United States at formal border crossings are turned around and sent back, violated an asylum seeker's fundamental rights under the Canadian Charter of Rights and Freedoms.

The ruling on Thursday said it was not the agreement itself that may have been causing the alleged infringements on the claimants’ rights, but the periodic reviews of the designation of the United States as a "safe" country as well as "related administrative conduct."

The challenge should have focused on those reviews, the ruling said, even though the government has kept them secret.

The ruling also said that the experiences of just 10 asylum seekers cited were not enough to draw conclusions about the U.S. immigration detention system and potential rights violations.

That is a problematic bar to set, said University of Ottawa immigration law professor Jamie Chai Yun Liew, adding the ruling and the continuation of the agreement fly in the face of the reputation Canada builds for itself as a champion of refugees.

"It erodes our commitment to refugee protection and also erodes our reputation in upholding the rights of refugees," she said.

Canada's government had argued it would suffer "irreparable harm" if the agreement were dissolved and asylum seekers allowed to enter through land-border crossings and make refugee claims.

"(The) STCA remains a comprehensive means for the compassionate, fair, and orderly handling of asylum claims," the government said in a statement on Thursday.

Lawyers for refugees may apply to be heard by Canada's Supreme Court.

Last year, a federal court ruled the agreement violated asylum seekers' right to life, liberty and security of the person because those who were turned back could be locked up indefinitely in immigration detention.

The refugees' lawyers also argued that people trying to make refugee claims that might be accepted in Canada, such as those on the grounds of gender-based discrimination, risked being sent back by the United States to their countries of origin.

During the administration of former U.S. President Donald Trump, tens of thousands of asylum seekers crossed into Canada between ports of entry to skirt the STCA, which only applies to formal border crossings.

Under COVID-19, however, Canada has a policy of turning back asylum seekers trying to cross irregularly. While it does not track what happens to them, at least a dozen ended up in U.S. immigration detention and at least one was deported.