A federal judge late Monday slapped down Donald Trump’s order to refuse asylum to migrants who illegally enter the United States.

U.S. District Judge Jon Tigar issued a temporary restraining order, after finding that the policy contradicted existing U.S. law and the expressed wishes of Congress.

The order means the government cannot enforce the tough new rules, announced by Trump earlier this month, until a court case proceeds on Dec. 19.

Citing national security concerns, the president signed an order on Nov. 9 that said no asylum claims would be considered from people who entered the country illegally — restricting asylum seekers to crowded “designated ports of entry.”

The order was designed to prevent caravans of Central Americans who have begun arriving U.S.’s southern border from claiming asylum in the country.

In his ruling, the judge said Trump’s order was an “extreme departure” that “irreconcilably conflicts” with the existing legislation, which stipulated that any foreign national could claim asylum on U.S. soil, regardless of whether they had entered through a designated port of arrival or not.

“Whatever the scope of the president's authority, he may not rewrite the immigration laws to impose a condition that Congress has expressly forbidden,” Tigar wrote.

Tigar’s ruling came in response to legal action brought by the American Civil Liberties Union and the Center for Constitutional Rights. “Individuals are entitled to asylum if they cross between ports of entry,” Baher Azmy, a lawyer for the Center for Constitutional Rights, told CNBC in response to the ruling. “It couldn’t be clearer.”

The Department of Justice may yet appeal the ruling, which comes as around 3,000 people from the caravans gather in Tijuana, Mexico, on the border with California.

Their arrival has sparked protests from Tijuana residents who fear their presence could lead the U.S. to shut the border. The U.S. temporarily shut its busiest crossing with Mexico, the San Ysidro border point on Monday to install wire-topped barriers.

Trump made the caravans a hot button issue ahead of this month’s midterms. After a period of quiet on the issue since the elections, the scenes in Tijuana prompted Trump to return to the subject Sunday. “The U.S. is ill-prepared for this invasion, and will not stand for it. They are causing crime and big problems in Mexico. Go home!”

According to Department of Homeland Security figures, the number of asylum applications in the U.S. has soared in recent years, from 5,000 in 2008 to 97,000 in 2018. The rise has mostly come from asylum seekers fleeing violence and poverty in Central American countries.

Yet as the number of migrants arriving swells, the U.S. military says that some of the troops that were controversially deployed to bolster the southwest border are already preparing to leave.

Army Lt. Gen. Jeffrey Buchanan, the general overseeing the 5,800-strong deployment, told Politico Monday that some of the soldiers would start coming home as early as this week, as they worked towards an end date of Dec. 15. Trump was accused of ordering the deployment to drum up fears about the impending migrant “invasion” ahead of the midterms.