WASHINGTON — The Supreme Court ruled Thursday for an Arizona church in a dispute over a town’s sign law in a decision that three justices said could threaten municipal sign regulations across the country.

The court unanimously agreed to strike down a law in Gilbert, Arizona, that set tougher rules for signs that direct people to Sunday church services than for signs for political candidates and real estate agents.

But the justices divided over why the law violated the rights of the Good News Presbyterian Church.

The church complained that the law forced the church to put up smaller signs than those for political candidates, real estate agents and others. The church’s signs also could be in place only for short periods of time.

Lower federal courts upheld the town’s sign ordinance.

Justice Clarence Thomas rejected that argument in his majority opinion for six of the nine justices. Thomas said political signs are “given more favorable treatment than messages announcing an assembly of like-minded individuals. That is a paradigmatic example of content-based discrimination.”

Under the rigorous review the court gives to laws that treat speakers differently because of content, the law must fall, Thomas said.

Justice Elena Kagan said she fears that all sign ordinances now will have to face the same strict review and many “are now in jeopardy” because of Thursday’s decision.

Justices Stephen Breyer and Ruth Bader Ginsburg joined Kagan’s opinion.

The Good News Presbyterian Church is led by Pastor Clyde Reed. The church and Reed sued Gilbert for treating religious groups more severely than others, alleging violation of the First Amendment’s guarantee of religious freedoms.

The sign ordinance struck down Thursday allowed directional signs, like the ones put up by the church inviting people to Sunday worship, to be no larger than 6 square feet. They had to be placed in public areas no more than 12 hours before an event and removed within an hour of its end.

Signs for political candidates, by contrast, can be up to 32 square feet and stay in place for several months.