The First Amendment protects a fringe church’s anti-gay protests at military funerals, a nearly unanimous Supreme Court ruled Wednesday in a powerful opinion that spoke to the nation’s tolerance for even hateful public speech.

The court’s most liberal and most conservative justices joined in a decision likely to define the term. It writes a new chapter in the court’s findings that freedom of speech is so central to the nation that it protects cruel and unpopular protests — even, in this case, at the moment of a family’s most profound grief.

Chief Justice John G. Roberts Jr. wrote that Westboro Baptist Church’s picketing at fallen soldiers’ funerals “is certainly hurtful and its contribution to public discourse may be negligible.” But he said the reaction may not be “punishing the speaker.”

“As a nation we have chosen a different course — to protect even hurtful speech on public issues to ensure that we do not stifle public debate,” Roberts said.

The court sided with a group on the outskirts of American life: a tiny family church in Topeka, Kan., that has drawn disdain across the nation for its protests of military funerals and its lewd signs proclaiming God’s hatred. Its message is that military deaths — and virtually any natural disaster — are divine punishment for the country’s tolerance of homosexuality.

At issue was the protest in 2006 at the funeral of 20-year-old Marine Lance Cpl. Matthew Snyder in Westminster, Md., who had been killed in Iraq — one of more than 600 funerals the group has picketed. His father, Albert, filed a lawsuit seeking damages, saying the group had turned the event into a “circus.”

Margie Phelps, the daughter of Westboro’s founder, the Rev. Fred W. Phelps, and a lawyer who argued the case before the court, called Wednesday’s decision a providential ruling that was more than she had hoped for.

It could encourage the group to challenge some of the more than 40 state and federal laws that seek to protect funerals from disruption, she said in a telephone interview.

Asked whether the decision would change the church’s tactics, Phelps said, “We’re going to picket more.”

The court’s lone dissenter was Justice Samuel A. Alito Jr., who said the First Amendment does not convey the right to “brutalize” private individuals.

“Our profound national commitment to free and open debate is not a license for the vicious verbal assault that occurred in this case,” he wrote.

Sean E. Summers, who represented Snyder, said his client was naturally disappointed and worried about other families who will be confronted by Westboro.

“Mr. Snyder’s not a lawyer,” Summers said. “He viewed this as a common-sense case.”

The church chose Matthew Sny­der’s funeral somewhat by chance; he was not gay. The group often pickets the funerals of military personnel and others not because of their sexual orientation but because of the potential for publicity.

The group recently turned up at the funeral of Elizabeth Edwards and declared that 9-year-old Christina Taylor Green, a victim of the Tucson shootings in January, was “better off dead.”

At the Westminster funeral, Fred Phelps and six other family members carried signs saying, among other things, “Thank God for Dead Soldiers,” “God Hates Fags” and “America Is Doomed.”

Plans for the protest were well publicized, and more than 1,000 people turned out to either support the Snyders or protest Westboro. The funeral procession was rerouted so as not to pass the Phelpses.

The parochial school across the street from the protesters papered over its windows to shield students from the signs, which included an illustration of two stick figures engaging in anal sex. The media were out in force. A SWAT team was called.

But the protesters were about 1,000 feet from the church where the funeral was held, and Snyder acknowledges that he could see only the tops of their signs. The funeral was not disrupted, and Snyder learned of the signs’ content while watching television coverage.

A Baltimore jury awarded Snyder more than $10 million for intentional infliction of emotional distress, intrusion upon seclusion and civil conspiracy claims. The award was cut in half by the judge and then overturned by the U.S. Court of Appeals for the 4th Circuit in Richmond. A three-judge panel said that although the rhetoric used was offensive, it was protected as speech concerning issues in the national debate.

The high court largely agreed.

Roberts said that a ruling in favor of the church was based on on several factors. One is that the speech was on matters of public controversy.

“While these messages may fall short of refined social or political commentary, the issues they highlight — the political and moral conduct of the United States and its citizens, the fate of our nation, homosexuality in the military, and scandals involving the Catholic clergy — are matters of public import,” he said.

And while he said the church’s protests near the funeral added “anguish” to Snyder’s “already incalculable grief,” the event was on public land under the dictates of local law enforcement.

“Westboro conducted its picketing peacefully on matters of public concern at a public place adjacent to a public street,” Roberts wrote. “Such space occupies a special position in terms of First Amendment protection.”

He noted that Maryland, as well as 43 other states and the federal government, has a law restricting funeral picketing. Roberts seemed to suggest that such laws could pass constitutional muster if they are “content neutral” but also noted that the 2006 protest would have complied with Maryland’s law, which was adopted since then.

Justice Stephen G. Breyer agreed with the majority opinion but wrote separately to emphasize that he read the ruling to concern only picketing. He raised concerns about attacks that were broadcast or posted on the Internet. The court did not take into consideration an “epic poem” that the church posted online that specifically attacked the Snyder family.

Alito said the decision will only encourage the group’s “outrageous” pattern of verbal attacks, which he said should be seen as the equivalent to physical assaults. “This is the strategy that they have routinely employed — and that they will now continue to employ — inflicting severe and lasting emotional injury on an ever growing list of innocent victims.”

Alito has set himself apart from the rest of the court on First Amendment matters. Last term, he was the lone dissenter when the court ruled that a federal law banning videos of animal cruelty was so broad it violated the Constitution.

Snyder, at a news conference near his home in York, Pa., said Wednesday: “My first thought was eight justices don’t have the common sense God gave a goat. . . . We found out today we can no longer bury our dead in this country with dignity.”

The case is Snyder v. Phelps .

Staff writer Jerry Markon and staff researcher Lucy Shackelford contributed to this report.