Canada’s Supreme Court on Friday upheld an asylum-seeker pact between Canada and the United States but sent the case back to a lower court to determine whether the contested agreement violates equality rights.

The verdict is a partial victory for the Canadian government, keeping the pact in place even as it sets it up for further judicial scrutiny.

Last year, almost 40,000 people crossed into Canada between formal crossings to file refugee claims – the vast majority crossing at Roxham Road in Quebec, at the border with New York state. That influx has strained Canada’s resources and prompted changes to the agreement.

Asylum seekers told Reuters they believe Canada has a swifter and more inclusive asylum system than the United States.

Under the Canada-U.S. Safe Third Country Agreement, which came into effect in 2004, asylum seekers crossing the land border between the two countries are sent back on the grounds they should apply for asylum in the first “safe” country they arrived in.

Built-in safety valves such as public policy exemptions that allow some asylum seekers to remain in Canada mean the agreement does not violate asylum seekers’ right to life, liberty and security of the person, the Supreme Court ruled. Refugee advocates argue these remedies are not practically available.

The court sent the case back to federal court for a ruling on whether the agreement breaches asylum seekers’ right to equal treatment under the law. Refugee advocates argue the agreement violates that right because they say the U.S. is less receptive to refugee claims based on gender.

Gauri Sreenivasan, co-executive director of the Canadian Council for Refugees, which brought the case, called on the government Friday to withdraw from the agreement.

“This is not the refugee system Canadians want,” Sreenivasan said.

Canadian Immigration Minister Sean Fraser said Canada has no plans to suspend the agreement, now that the Supreme Court has affirmed its validity.

Refugee advocates told Reuters they were heartened by the equality rights directive but disappointed in the court’s decision to keep the agreement in place on the other Charter ground.

“This means that the border remains closed and it’s not a good day for refugees,” said Jamie Chai Yun Liew, who represented a party intervening in the case.

The U.S. and Canada amended the agreement earlier this year, applying it to the entire length of the border as opposed to only at formal crossings.

Since the amendment, the number of asylum seekers crossing irregularly into Canada has plummeted. Between March 25 and May 28, 618 asylum seekers crossed between ports of entry and were referred to the Canada Border Services Agency, according to agency figures.

But the number of people caught crossing into the U.S. spiked in March to 992 from 630 in February and stayed high in April, U.S. Customs and Border Patrol figures show.

Twice, Canadian federal courts have struck down the agreement and, twice, appeals courts have upheld it. This was the first time the Supreme Court had heard the case.