DES MOINES (AP) — A federal judge struck down Iowa laws that ban the desecration of the American flag, ruling Wednesday that they criminalize free speech.

The laws are “unconstitutionally overbroad” because they outlaw a substantial amount of protected expression while having few legitimate applications, U.S. District Judge Robert Pratt wrote in a 25-page decision.

One law makes it a misdemeanor to deface, mutilate, trample on or take a range of other actions seen as mistreating the American flag. The other makes it misdemeanor disorderly conduct to show disrespect to the flag in order “to provoke or encourage another to commit a public offense.”

Pratt’s ruling directs prosecutors not to enforce those laws.

The ruling came in a lawsuit filed last year by the American Civil Liberties Union of Iowa on behalf of Westboro Baptist Church of Topeka, Kansas. The church’s members are known for protesting outside funerals with anti-gay messages, and they often drag, stand and spit on flags during their protests.

Law enforcement officials in Red Oak, Iowa, threatened to enforce the laws against church members during protests outside funerals in 2010 and 2012. Members said they declined to use the flag to express themselves for fear of being arrested, chilling their First Amendment rights.

The Iowa attorney general’s office had argued the laws were constitutional and that church members had no standing to sue since they weren’t charged. The office had no immediate comment Wednesday, a spokesman said.

Randall Wilson, general counsel at the ACLU of Iowa, said Pratt’s decision “returns Iowa to the fold of states that view freedom of speech as the touchstone of a free and democratic society.”

“We celebrate this decision as a victory for American principles and values,” he said in a statement.

Pratt had ruled in 2007 that Iowa’s previous flag desecration laws were unconstitutional because they were too vague, saying it was unclear how terms such as “flag” and “disrespect” were defined. In response, lawmakers amended them to be more specific.

In his ruling Wednesday, Pratt reversed his 2007 conclusion that the laws were not unconstitutional on free speech grounds. He said the federal appeals court that governs Iowa has since struck down a similar Missouri law, setting a new precedent.