In a key test of free speech protections in the US, the supreme court has heard arguments about whether a fundamentalist church had the right to picket a marine's funeral with signs like "Thank God for Dead Soldiers".

Members of the Westboro baptist church in Topeka, Kansas, protested at the 2006 funeral of Lance Corporal Matthew Snyder to express their view that US deaths in Afghanistan and Iraq were God's punishment for US immorality and tolerance of homosexuality and abortion.

They were fined $5m (£3.1m) for intentional infliction of emotional distress, but an appeals court threw out the verdict on the grounds that the first amendment to the US constitution guarantees the right of free speech.

Now the dead marine's father, Albert Snyder, is asking the supreme court to reinstate the original verdict.

Yesterday, a Westboro church member, Margie Phelps, told the court that the message of the protests at military funerals and elsewhere was: "Nation, hear this little church. If you want them to stop dying, stop sinning."

But in a rare public display of sympathy, the justices strongly suggested they would like to rule in favour of Albert Snyder.

"This is a case about exploiting a private family's grief," said Justice Ruth Bader Ginsburg, who questioned whether the first amendment should protect the church members.

Could a wounded soldier sue someone who demonstrated "outside the person's home, the person's workplace, outside the person's church ... saying these kinds of things: 'You are a war criminal,' whatever these signs say or worse?" Justice Elena Kagan asked.

Justice Samuel Alito wanted to know if the constitution would shield someone who delivered a mean-spirited account of a soldier's death to the serviceman's grandmother while she was leaving her grandson's grave. "She's waiting to take a bus back home," Alito imagined, and someone approaches to talk about the roadside bomb that killed the soldier. "'Let me describe it for you, and I am so happy that this happened. I only wish I were there. I only wish that I could have taken pictures of it.' And on and on. Now, is that protected by the first amendment?"

Westboro members held signs outside Snyder's funeral, including ones that read "You're Going to Hell" and "God Hates the USA". The 20-year-old marine was killed in a military vehicle accident.

The church posted a poem on its website that criticised Albert Snyder and his former wife for the way they raised Matthew.

Phelps said the court had never allowed a speaker to be held liable for remarks on a topic of public interest, in this case US war deaths. She suggested the court would find it difficult to draw a line that would protect grieving families without imposing significant limits on unpopular speech.

Albert Snyder was originally awarded $11m in his suit against the church for intentional infliction of emotional distress, among other claims. A judge reduced the amount to $5m, then the federal appeals court in Richmond, Virginia, threw out the verdict altogether.

One possibility suggested by Justice Antonin Scalia was that the supreme court could order a new trial.

Westboro members, led by the Reverend Fred Phelps, have picketed many military funerals. They welcome the attention the protests have brought, mocking their critics and vowing not to change their ways whatever the outcome at the supreme court.

Church members marched in front of the court with placards like those they have been carrying to funerals. A line of people trying to get into the court stretched around the corner of the building at Capitol Hill.

Albert Snyder said the case was not about free speech but harassment. "I had one chance to bury my son and it was taken from me."

His lawyer, Sean Summers, told the justices that the protest was unprotected by the constitution because of the "personal, targeted nature of the attack on the Snyder family".

Forty-eight states, 42 senators and veterans groups have sided with Albert Snyder, asking the court to shield funerals from the church's "psychological terrorism".

While distancing themselves from the church's message, media organisations, including the Associated Press, have called on the court to side with the Westboro church because of concerns that a victory for Albert Snyder could erode the right to free speech.