Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A Florida judge has ruled that Miami-Dade’s policy of holding undocumented immigrants in jail at the request of the federal government is unconstitutional.

Eleventh Judicial Circuit Judge Milton Hirsch on Friday called the policy a violation of the Tenth Amendment five weeks after Miami-Dade Mayor Carlos Gimenez decided the city would no longer be considered a “sanctuary” for undocumented immigrants.

James Lacroix — a Haitian national who pleaded guilty to a felony charge of habitually driving on a suspended license in Miami-Dade — and his attorney, Philip Reizenstein, brought the case before Hirsch earlier this week. Lacroix was supposed to be released on time served, but remained in custody at the request of U.S. Immigration and Customs Enforcement.

In his ruling, Hirsch said the county has neither a reason nor a basis in law to keep him in prison. Hirsch added that the federal government is constitutionally prohibited from forcing the county to make Lacroix a prisoner, and the county is prohibited from complying with that demand.

James Lacroix, of Miami-Dade, Florida, plead guilty to a felony charge of driving on a suspended license, but wasn't released from jail despite being scheduled for release on time served. Miami-Dade Police Department

“This isn’t an immigration issue. It’s a detention issue,” Reizenstein told NBC News after the ruling was announced. He said the federal government has taken Lacroix into custody, and that they could deport him faster as retribution for the case.

“This doesn’t help [Lacroix] — he’s probably going to be deported, but this will help everyone else. [The ruling] is a direct blow to the president and his executive order,” Reizenstein said. “It’s a courageous blow by this judge.”

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

Reizenstein said he took on Lacroix’s case pro bono after he went to court on Tuesday for a different matter and saw the man plead guilty to a crime for which he had already served his sentence and not be released.

Gimenez agreed to drop Miami-Dade’s sanctuary status on Jan. 26, after President Donald Trump issued an executive order eliminating most federal funding for cities with sanctuary policies in place.

Related: Mayor’s Switch on Immigration Detention Protested in Miami-Dade

In compliance with the president’s order, Gimenez agreed to allow county jails to hold immigrants for the federal government who could potentially be deported. Miami-Dade County had not been complying with the federal government on these orders since 2013, according to Hirsch’s ruling.

“This case should appeal to conservatives all over country, but they’re not conservative. They’re anti-immigrant, and in this case the president of the United States blackmailed the county, and the mayor buckled,” Reizenstein said.

Lacroix, 45, legally entered the United States under emergency status given to Haitian nationals following the 2010 earthquake, according to Reizenstein. He was arrested several times for driving on a suspended license. His most recent arrest happened in early January.

Lacroix was also previously charged with battery and aggravated assault, but those charges were dropped, according to the Miami-Dade Clerk of Courts.

The federal government made the request for the county to hold Lacroix two days after Gimenez changed the city's sanctuary status, according to the Miami Herald.

Judge Milton Hirsch speaks at a hearing on March 3, 2017, where he ruled on the legality of the country's decision to cooperate with immigration agents seeking to deport people who have been in jail. Roberto Koltun / The Miami Herald

Just before the ruling in his favor, Lacroix was taken into federal custody, Reizenstein said.

“Miami is not, and has never been, a sanctuary city,” Hirsch wrote in his ruling. “But America is, and has always been, a sanctuary country.”

The mayor’s office tweeted a statement via spokesman Mike Hernandez that "immigration is a federal issue which should be handled in federal court. Miami-Dade County is planning an immediate appeal to the Third District Court of Appeal."

Related: 'Sanctuary Cities' Vow to Resist Trump Order Despite Funding Threat

It’s unclear what effect Hirsch's ruling will have on the city or Trump’s order. Reizenstein says he hopes it will give other lawyers in the county a guide to get their unconstitutionally imprisoned clients out as well.

“Were going to publish this order so other lawyers will have a blueprint to get their clients released,” Reizenstein said. “We hope other judges will be as courageous.”