Good News Community Church Pastor Clyde Reed, center, and his wife, Ann, leave the Supreme Court in January. The justices sided with the church Thursday over limits on roadside signs in Gilbert, Ariz. (Susan Walsh/AP)

The Supreme Court on Thursday struck down an Arizona town’s ordinance that treated signs directing people to a small church’s worship services differently than signs with other messages, such as a political candidate’s advertisement.

The decision was unanimous in favor of the tiny Good News Community Church, which has a long-running dispute with the town of Gilbert, Ariz., over signs planted in public rights of way directing congregants to church meeting places.

But the justices split over the correct way to decide the case.

Five justices joined Justice Clarence Thomas’s decision that the town’s regulations are based on the content of the sign’s message and thus require the court’s highest First Amendment protection.

The town “singles out specific subject matter for differential treatment, even if it does not target viewpoints within that subject matter,” Thomas wrote. “Ideological messages are given more favorable treatment than messages concerning a political candidate, which are themselves given more favorable treatment than messages announcing an assembly of likeminded individuals.”

Thomas wrote, “That is a paradigmatic example of content-based discrimination.”

He was joined by Chief Justice John G. Roberts Jr. and Justices Antonin Scalia, Anthony M. Kennedy, Samuel A. Alito Jr. and Sonia Sotomayor.

Justice Elena Kagan agreed that Gilbert’s ordinance was problematic. But she said the court had gone too far in saying such regulations should receive the court’s most exacting scrutiny. Under the majority’s test, she said, few sign laws are safe.

“The consequence — unless courts water down strict scrutiny to something unrecognizable — is that our communities will find themselves in an unenviable bind: They will have to either repeal the exemptions that allow for helpful signs on streets and sidewalks, or else lift their sign restrictions altogether and resign themselves to the resulting clutter,” Kagan wrote. She was joined by Justices Ruth Bader Ginsburg and Stephen G. Breyer.

The church, which has no permanent home, contended it is being treated differently than politicians, homeowner associations and builders. Signs for political candidates, for instance, can be larger and stay up longer than “directional” signs, which can be planted only 12 hours before a service and must be removed an hour after the event ends.

The case is Reed v. Town of Gilbert.

More Supreme Court news:

Supreme Court lets stand ruling that struck down N.C. abortion law

Justices say it’s enough to cite terrorism in declining visa applicant

Supreme Court says president’s powers prevail on foreign borders