(CNN) -- A federal judge in Texas has ordered the Biden administration to revive a Trump-era border policy that required migrants to stay in Mexico until their U.S. immigration court date.
Shortly after President Joe Biden took office, he ended the policy known as "remain in Mexico" that resulted in thousands of non-Mexican migrants having to wait in Mexico until their immigration hearings, often in dangerous conditions.
In April, the state of Texas and the state of Missouri sued the Biden administration, arguing that reversing the policy led to a surge of migrants at the U.S.-Mexico border that inflicted costs on the states.
A couple months later, Homeland Security Secretary Alejandro Mayorkas formally ended the policy in a June memo, and the administration later worked to admit those migrants who had been subject to it.
But late Friday, Judge Matthew Kacsmaryk, a Trump appointee, blocked the administration from implementing that memo, though he stayed his order for seven days "to allow the federal government time to seek emergency relief at the appellate level."
Kacsmaryk said that the Biden administration's termination of the policy violated the Administrative Procedure Act, a law that dictates what procedures agencies must go through to implement certain policies.
Specifically, the judge said that Mayorkas "failed to consider several of the main benefits of" the policy known as the Migrant Protection Protocols in his June memo, nor did he discuss the rise in border crossings.
Kacsmaryk also concluded that one of the key reasons the memo did provide for ending the policy was arbitrary, in violation of the APA, which prohibits agencies from taking "arbitrary" and "capricious" actions.
The policy -- which was an unprecedented departure from previous protocols -- was put into effect in 2019 by a memo from then-Homeland Security Secretary Kirstjen Nielsen. An estimated 68,000 migrants were returned to Mexico under the policy.
For those subject to it, that meant waiting months, if not years, in squalid conditions and under the threat of extortion, sexual assault and kidnapping.
The APA, cited in Friday's ruling, is a law that foes of the Trump administration used to block several of its key moves. It was the basis of the Supreme Court's decision to halt the Trump administration's termination of the Deferred Action for Childhood Arrivals program in 2020, as well as the Supreme Court's decision to block Trump's census citizenship question.
More recently, it was the law that was the basis of a judge's decision in Texas last month that ruled that DACA itself was unlawful.
(The-CNN-Wire™ & © 2021 Cable News Network, Inc., a Time Warner Company contributed to this report. All rights reserved.)
for more features.