In a case that will test the White House’s ability to set immigration policy, the Supreme Court debated on Tuesday whether the Biden administration can terminate a Trump-era border policy known as “Remain in Mexico.”

Some conservatives on the court grilled the administration with tough questions and expressed sympathy for lower court rulings that favored President Joe Biden.

At one point, Justice Samuel Alito implied that the lower courts were correct in holding that the Trump program might be required to comply with immigration law. And, according to Justice Clarence Thomas, the government only has limited discretion in deciding whether or not to parole those who arrive.

Chief Justice John Roberts, on the other hand, expressed sympathy for the government’s position that it wants to end a program started by the previous administration. He appeared perplexed as to how to respond to lower court decisions interpreting immigration law to require the program — or something similar to it.

Meanwhile, the court’s three liberals sided with the Biden administration, arguing that requiring the program’s continuation would have serious diplomatic ramifications. By the end of the debates, it was unclear whether there were five votes in favor of Biden’s position.

If the court ordered the Biden administration to continue implementing a program that is so reliant on Mexico’s cooperation, Justice Elena Kagan expressed concern about diplomatic implications. She claimed that such a decision would subject the US to the “mercy of Mexico” and that it could change its mind at any time in response to changing circumstances.

When a Texas lawyer defending the Trump-era program said that diplomatic relations would not be an issue, Kagan said, “So, what are our options? Bringing truckloads of people into Mexico without first negotiating with the Mexican government?”

Instead of detaining or releasing non-Mexican citizens who entered the US, the Department of Homeland Security launched an unprecedented program in 2019 that sent them back to Mexico while their immigration cases were being processed.

Critics call the policy inhumane, claiming it puts asylum seekers with valid claims in perilous situations. Migrants living in makeshift camps along Mexico’s northern border have been subject to the program, which is officially known as Migrant Protection Protocols.

Remain in Mexico is distinct from the public health authority known as Title 42, which allows border officials to turn back migrants caught at the border, effectively barring them from seeking asylum, whereas “remain in Mexico” still allows them to do so.

Tuesday’s case, as well as the political fallout from the Biden administration’s attempt to repeal Title 42 next month, have once again highlighted the White House’s politically precarious position and the uphill legal battles it faces. The program was originally terminated by Biden’s Department of Homeland Security in June of last year. A district judge vacated the memo and ordered the policy to be reinstated after two states filed a challenge, Texas and Missouri.

The court ruled that the administration had violated the federal Administrative Procedure Act by failing to adequately explain its decision-making process in its attempt to end the program. Further, the court interpreted immigration law to require the DHS to return certain noncitizens to Mexico when it lacks the funds to detain them on US soil, despite long-standing discretion that allows authorities to choose who to release or detain.

Last fall, the DHS tried again, issuing a new memo that provided a more thorough explanation of its decision to end the program, but an appeals court ultimately upheld the district court’s decision, refusing to even consider the new memo’s reasoning, implying that it was too late.

According to the International Organization for Migration, more than 2,300 migrants have been sent back to Mexico under the “Remain in Mexico” policy since it was renewed late last year.

The justices concentrated on various aspects of immigration law. The Department of Homeland Security “shall” detain noncitizens pending their immigration proceedings in one section, while the Secretary “may” return certain noncitizens in another.