WASHINGTON — The Supreme Court on Thursday unanimously ruled that an Arizona town had violated the First Amendment by placing limits on the size of signs announcing church services.

The case, Reed v. Town of Gilbert, No. 13-502, concerned an ordinance in Gilbert, Ariz., that has differing restrictions on political, ideological and directional signs. It was challenged by a church and its pastor.

All of the justices agreed that the distinctions drawn by the ordinance were impermissible. But they divided 6 to 3 on the rationale, with the majority saying that all content-based laws require the most exacting form of judicial review, strict scrutiny, one that is exceptionally hard to satisfy.

“Content-based laws — those that target speech based on its communicative content — are presumptively unconstitutional and may be justified only if the government proves that they are narrowly tailored to serve compelling state interests,” Justice Clarence Thomas wrote for the majority.