A federal judge late Wednesday temporarily blocked most of Texas' tough new sanctuary cities law that was set to go into effect September 1.

The law would have let police officers ask people during routine stops whether they're in the U.S. legally or not.

The law, known as Senate Bill 4, had been championed by President Donald Trump's administration and was set to take effect Friday.

U.S. District Judge Orlando Garcia temporarily blocked most of Texas' tough new sanctuary cities law that was set to go into effect September 1 - which would have allowed police officers ask people during routine stops whether they're in the U.S. legally or not

It was widely viewed as the toughest immigration measure in the nation since Arizona passed what critics called a Show Me Your Papers law in 2010, which was later partially struck down by the U.S. Supreme Court.

The ruling by U.S. District Judge Orlando Garcia in San Antonio was handed down as anxieties about immigration enforcement in Texas have again flared in the wake of Tropical Storm Harvey.

Houston officials have sought to assure families fleeing the rising floodwaters in the nation's fourth-largest city that shelters would not ask for their immigration status.

Houston police Chief Art Acevedo, an outspoken critic of the law, got word of the decision while standing inside a downtown convention center where about 10,000 people have sought shelter. He high-fived another officer.

'We needed a break. That's a break for us,' said Acevedo, whose department has conducted thousands of high-water rescues and lost one officer who died in floodwaters as he tried to drive to work.

The sanctuary cities law, known as Senate Bill 4, had been championed by President Donald Trump's administration and was set to take effect Friday

The measure sailed through the Republican-controlled Legislature despite months of protests and opposition from business groups, which worried that it could cause a labor-force shortage and send a negative economic message.

Leading the lawsuit were Texas' largest cities - including Houston, Dallas, San Antonio and Austin - in a state where the Hispanic population has grown at a pace three times that of whites since 2010.

Garcia wrote in his 94-page ruling that Texas' law was preempted by existing federal statute and therefore unconstitutional.

The judge noted that when it was being considered in public legislative hearings, only eight people testified in favor of it while 1,600 'showed up to oppose it.'

He also wrote there 'is overwhelming evidence by local officials, including local law enforcement, that SB 4 will erode public trust and make many communities and neighborhoods less safe.'

In June Lydia Balderas (L) and Merced Leyua (R) join others as they protest against a new sanctuary cities bill outside the federal courthouse in San Antonio

He added that: 'localities will suffer adverse economic consequences which, in turn, will harm the state of Texas.'

'The court cannot and does not second guess the Legislature,' Garcia wrote.

'However, the state may not exercise its authority in a manner that violates the United States Constitution.'

Garcia's order suspends the law's most contentious language while suggesting that even parts of the law that can go forward won't withstand further legal challenges.

Republican Gov. Greg Abbott, who signed the law in May, said Texas would appeal immediately and expressed confidence that the state would eventually prevail.

He also again took a swipe at the elected Democratic sheriff of Travis County, Sally Hernandez, who had announced on the day of Trump's inauguration that her Austin jails would no longer automatically honor all detainer requests made by U.S. Immigration's and Customs Enforcement.

'Today's decision makes Texas' communities less safe. Because of this ruling, gang members and dangerous criminals, like those who have been released by the Travis County Sheriff, will be set free to prey upon our communities,' Abbott said in a statement.

Texas Gov. Greg Abbott speaks during a press briefing the State of Texas Emergency Command Center at Department of Public Safety headquarters in Austin, Texas

The U.S. Department of Justice, which has made 'sanctuary cities' a new priority under the Trump administration, had joined Texas is defending the law in court. U.S. Attorney General Jeff Sessions has threatened to pull federal money from jurisdictions that hinder communication between local police and immigration authorities and has praised Texas' law.

The law had sought to fine law enforcement authorities who fail to honor federal requests to hold people jailed on offenses that aren't immigration related for possible deportation.

Opponents of the law told Garcia that his ruling could determine if other states pursue copycat measures, while the Texas attorney general's office argued that the new law had fewer teeth than the Arizona measure.

Since January, the bill has elevated political tensions in Texas, and it boiled over in May when Republican state Rep. Matt Rinaldi told Democrats that he had called federal immigration agents to report protesters in the Capitol who he said were holding signs that said they were not legal citizens.

A Democrat whose district is near the U.S.-Mexico border admitted confronting and pushing Rinaldi, who has acknowledged telling him that he would 'shoot him in self-defense.'