WASHINGTON—The First Amendment protects free speech even if it is as hurtful as signs at a Marine funeral proclaiming "Thank God for Dead Soldiers," the Supreme Court ruled Wednesday in a decision that was one of the court's most significant on freedom of expression in recent years.

The Westboro Baptist Church celebrated the death of Lance Cpl. Matthew Snyder in Iraq with signs such as "God Hates You," along with antigay messages at his funeral in Maryland in 2006. The late Marine's father sought damages for emotional distress,...