DES MOINES, Iowa — A new law in Iowa that makes it a crime to be in the state if previously denied admission to the U.S. conflicts with federal law and could lead to the deportation of people who are legally in the country, civil rights and immigrant rights groups argue in a federal lawsuit filed Thursday.

The suit marks the first legal action taken against Iowa in response to the law, though the U.S. Department of Justice warned the state's top officials last week that the agency would sue unless they agreed not to enforce it.

The complaint filed in U.S. District Court alleges that the new statute steps on the federal government's authority to enforce immigration law. The law is similar to a more expansive Texas statute that has been challenged by both the Justice Department and civil rights groups.

''This ugly law is deeply harmful to Iowa families and communities," said Rita Bettis Austen, legal director of The American Civil Liberties Union of Iowa. ''Iowa lawmakers knowingly targeted people who are protected by federal immigration laws and who are legally allowed to be here.''

Iowa Attorney General Brenna Bird said Thursday that the state would not back down, and that the law existed because President Joe Biden hasn't secured the southern border.

''Iowa's law is not unique; it simply enforces immigration laws while Biden refuses to," Bird said in a written statement. "Iowa stands ready to defend our immigration law that keeps Iowa communities safe.''

The ACLU of Iowa, national ACLU and the American Immigration Council filed the suit Thursday on behalf of the Iowa Migrant Movement for Justice and two individual Iowans.

The Iowa law has increased fear among immigrant communities in the state that enforcement would lead to racial and ethnic profiling, complicate interactions with police or dissuade community members from reporting crime. Activist and advocacy groups, including one named in the suit, have hosted gatherings to try to answer people's questions and organized protests in response.

Texas was allowed to enforce the law for only a few confusing hours in March before it was put on hold by a federal appeals court's three-judge panel. The panel heard arguments by both supporters and opponents in April, and will next issue a decision on the law's constitutionality.

Some law enforcement officials and legal experts have said unanswered questions remain about how the laws in Iowa and Texas would be implemented, since enforcement of immigration law has historically fallen to the federal government and is a binational process.

The Iowa law, which goes into effect on July 1, would allow criminal charges to be brought against people who have outstanding deportation orders or who previously have been removed from or denied admission to the U.S. Once in custody, migrants could either agree to a judge's order to leave the U.S. or be prosecuted, potentially facing time in prison before deportation.

The Iowa lawsuit contends that the law conflicts with federal law and could direct police to arrest people who are authorized to be in the U.S., such as people who have been granted asylum or have visas. The suit said the law could result in the prosecution of children brought to Iowa by their parents.

"It will create absolute chaos and human suffering in our legal system, and harm Iowa communities,'' said Melloy Goettel, legal director at the American Immigration Council.

Gov. Kim Reynolds, a Republican who signed the new legislation into law, reiterated her support for the change.

''As Governor, I have a responsibility to protect the citizens of Iowa," Reynolds said in a written statement that repeated the arguments of other Republican leaders. "Since President Biden refuses to enforce our nation's immigration laws — threatening the safety of our citizens — Iowa will step in.''