AUSTIN, Texas (Reuters) - The heavily Hispanic Texas border county of El Paso filed suit in federal court on Monday to halt a new law backed by the state’s Republican leaders to punish “sanctuary cities,” saying the measure was vague, cruel and unconstitutional.

The law in Texas, which has the longest border with Mexico of any U.S. state, takes effect on Sept. 1 and calls for jail time for police chiefs and sheriffs who fail to cooperate in U.S. immigration enforcement.

The suit filed in a U.S. district court in San Antonio on behalf of the county and its sheriff names Republican Governor Greg Abbott and others as defendants. It said the law would invite unlawful racial profiling in the county of about 800,000 people where more than 80 percent of the population is of Hispanic heritage.

“History and logic supports that all Texans will not be equally subject to this harassment,” the lawsuit said.

Abbott has said the law known as Senate Bill 4 will keep criminals off of the streets. Republican backers said there were no major sanctuary cities in Texas and the law would prevent any from adopting such practices.

It was the first such legislation approved by a state since Republican Donald Trump, who has called for a crackdown on illegal immigration, became president in January.

The Texas law allows police to ask people about their immigration status during a lawful detention.

Supporters have said immigrants who do not break the law have nothing to fear, while critics contend it allows police to detain people for up to 48 hours for immigration checks, even for minor infractions such as jaywalking.

Earlier in May, the small Texas border town of El Cenizo, filed suit against the Texas law in federal court, and many major Texas cities and counties have said they also intend to sue to halt its implementation.

The Texas law has also faced criticism from the police chiefs of the state’s largest cities, who said it would divert resources from fighting crime to immigration law enforcement.

They added it would widen a gap between police and immigrant communities and eliminate the potential for assistance from immigrants in solving or preventing crimes.

In a newspaper editorial last week, Abbott along with the sheriff of Hidalgo County, a border county with about the same population as El Paso, said SB 4 specifically prohibited racial profiling and discrimination.