The Department of Homeland Security on Monday said it is moving to end the Trump-era "Remain-in-Mexico" policy – marking the end to a years-long battle and coming amid a massive migrant crisis at the southern border.

The agency announced that, in light of a U.S. District Court’s removal of an injunction that required the implementation of the program – officially called the Migrant Protection Protocols (MPP) – it will end "in a quick, and orderly manner."

MPP was implemented and later expanded by the Trump administration during the 2019 migrant crisis after negotiations with Mexico. The controversial program saw migrants returned to Mexico for the duration of their immigration hearings rather than released into the U.S. It resulted in tent courts being set up along the southern border, and nearly 70,000 migrants returned under the program.

Proponents hailed the program as a success, arguing that by not releasing migrants into the U.S., it reduced the pull factors bringing them north while also cutting down on fraudulent asylum claims. Critics called the policy cruel and pointed to camps that resulted in Mexico where migrants were at risk of kidnapping and violence.

REPUBLICANS, HAWKS FEAR BORDER CRISIS WILL GET WORSE AFTER SCOTUS ‘REMAIN-IN-MEXICO’ RULING

Department of Homeland Security Secretary Alejandro Mayorkas testifies

Homeland Security Secretary Alejandro Mayorkas has attempted to end the Migrant Protection Protocols, but has been blocked by a court order. (Stefani Reynolds/AFP via Getty Images)

Then-candidate Joe Biden pledged to end the program if elected, and soon after entering office the Biden administration shut it down and released those enrolled in the program into the U.S. DHS Secretary Alejandro Mayorkas claimed the policy was not only cruel but ineffective.

"As Secretary Mayorkas has said, MPP has endemic flaws, imposes unjustifiable human costs, and pulls resources and personnel away from other priority efforts to secure our border," the DHS statement on Monday said.

However, Republican states pushed back and sued, arguing that the program was ended unlawfully and that the increased number of illegal immigrants would hurt their states, including by increasing the strain on their social services like health care and education.

Judge Matthew Kacsmaryk sided with the states and imposed a preliminary injunction, ordering the administration to re-implement the program. That injunction was upheld by the Supreme Court as the case was heard.

SUPREME COURT HANDS BIDEN VICTORY, ALLOWS END TO ‘REMAIN IN MEXICO’ POLICY

The program was re-established by the Biden administration, but only a few thousand migrants were enrolled in it – a fraction of the hundreds of thousands of migrants hitting the U.S. southern border each month as the crisis raged on.

In June, the Supreme Court ruled that the administration did have the authority to end the program, sending it back to the district court – which has now lifted the injunction.

In its statement, DHS said migrants are no longer being enrolled in the program, and those currently enrolled will be taken out of it when they return for their next court dates.

CLICK HERE TO GET THE FOX NEWS APP

Meanwhile, there have been more than 200,000 migrant encounters along the southern border each month for the last four months, with an approximate 500,000 gotaways since the fiscal year began in October.

The Biden administration has been seeking to end the Title 42 public health order – which has seen the expulsion of more than half of all migrants since March 2020 due to the COVID-19 pandemic. However, ending the policy has so far been blocked by a court order.