The U.S. Supreme Court ruled Wednesday that an anti-gay church has the legal right to picket military funerals, CNN reported.

The Topeka, Kansas-based Westboro Baptist Church claims it protests the funerals of fallen soldiers with signs that read “Thank God for dead soldiers” and “AIDS cures fags” because their deaths are the price America pays for its acceptance of “the sin of homosexuality.”

In an 8-to-1 vote, the court said that the group had a right to promote its message, upholding a 2008 federal appeals court ruling which reversed a lower court decision that awarded millions of dollars to the father of a fallen Marine, who had sued the church claiming emotional distress.

“Speech is powerful. It can stir people to action, move them to tears of both joy and sorrow, and – as it did here – inflict great pain. On the facts before us, we cannot react to that pain by punishing the speaker,” Chief Justice John Roberts said in writing for the majority.

Albert Snyder sued the small church in 2007 after it picketed the funeral of his son, Matthew Snyder.

Roberts added that the Snyder family was not a “captive audience” to the church's protests.

“Westboro stayed well away from the memorial service. Snyder could see no more than the tops of the signs when driving to the funeral. And there is no indication that the picketing itself in any way interfered with the funeral itself,” Roberts wrote.