SAN ANTONIO (Reuters) - A small Texas town on the Mexico border filed suit in federal court on Tuesday seeking to throw out on U.S. constitutional grounds a new Texas law that aims to punish so-called “sanctuary cities.”

FILE PHOTO: Texas Governor Greg Abbott speaks at a campaign rally for U.S. Republican presidential candidate Ted Cruz in Dallas, Texas February 29, 2016. REUTERS/Mike Stone/File Photo

El Cenizo, near Laredo, said it has offered refuge since before Texas, the largest Republican-controlled state, was part of the United States. It said the new law forces it and other localities to forgo their duties to serve and protect at home to become de facto immigration agents.

“The use by the state of city and county resources for federal immigration enforcement breeds distrust of local government and officials, who have no power to change federal laws, and can also wrench apart family and community structures,” said the lawsuit.

The Texas law signed by Republican Governor Greg Abbott on Sunday takes effect on Sept. 1. It comes as Republican U.S. President Donald Trump has made combating illegal immigration a priority.

Texas, with the longest border with Mexico of any U.S. state, has been at the forefront of the immigration debate.

The lawsuit, filed in U.S. District Court in San Antonio by El Cenizo’s mayor and others, named Abbott and Republican Attorney General Ken Paxton as defendants.

On Monday, Paxton filed a lawsuit on Texas’ behalf in a U.S. district court seeking to have the law, known as Senate Bill 4, declared constitutional, calling it “a vital step in securing our borders.”

The Texas law, the first such measure passed since Trump took office, calls for jail time for police chiefs and sheriffs who fail to cooperate in immigration enforcement.

The law also allows police to ask people about their immigration status during a lawful detention, even for minor infractions.

Critics said this could be used for unconstitutional racial profiling, while supporters have said immigrants who do not break the law have nothing to fear.

San Antonio Police Chief William McManus said the law could divert police resources and added that it has sent a chill through immigrant communities, who fear that cooperating with police could cause them to come under immigration status review.

“There’s nothing positive that this bill does in the community or in law enforcement,” he told a news conference on Tuesday.

Separately, the American Civil Liberties Union issued a “travel alert” for anyone going to Texas in the near future, warning that their constitutional rights could be violated due to SB 4.