AUSTIN, Texas (Reuters) - A U.S. district judge in Austin has rejected an effort by Texas to have a law that would punish so-called sanctuary cities be declared constitutional ahead of the measure taking effect next month. The Republican-backed law is the first of its kind since Republican Donald Trump became president in January, promising a crackdown on illegal immigrants and localities that protect them. Texas is the U.S. state with the longest border with Mexico.  U.S. District Judge Sam Sparks, appointed under Republican President George H.W. Bush, dismissed the case without prejudice late on Wednesday. The brief ruling did not give a reason. Senate Bill 4 calls for jailing police chiefs, sheriffs and possibly frontline officers who fail to cooperate with U.S. immigration officials. The measure also allows police to ask about immigration status during a lawful detention. After the law was approved in May, Texas sued major urban areas, including Austin, El Paso and Houston, as well as civil rights groups, saying they backed policies of non-cooperation with federal immigration officials. At a June hearing, Sparks asked why a court should declare the law constitutional before it took effect on Sept. 1. He also questioned why he should hear the case when most of the parties were part of a separate lawsuit over the same law being heard in a federal court in San Antonio. The defendants contended they had abided by federal law and the suit should be dismissed because Texas had no evidence showing it had been harmed by a law not yet in effect. Republican Texas Attorney General Ken Paxton said on Wednesday he was disappointed with the ruling on what he called an “undoubtedly constitutional law.” The American Civil Liberties Union, a civil rights group that has argued in court against the law, on Thursday said the Texas suit was a farce aimed at distracting attention from the harm that would come with SB 4. “This is a significant blow to the State, and its legal posturing has only resulted in wasted taxpayer money,” Edgar Saldivar, senior staff attorney of the ACLU of Texas, said in a statement.   In the federal case in San Antonio, a small border town and some of the largest Texas cities told a judge in June that SB 4 could lead to an immigration police state and establish illegal racial profiling. They asked the court to halt it, saying it was unconstitutional. 