Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

The US Supreme Court said Monday that the government cannot base a prosecution for sending an Internet threat solely on how the message was perceived.

Although the ruling was based on interpreting criminal law, and not on the First Amendment, it amounted to another strongly pro-free expression decision from the court under Chief Justice John Roberts.

The justices threw out the conviction of a Pennsylvania amusement park worker, Anthony Elonis, who began posting threatening message on Facebook in 2010 after his wife left him and took their two children.

One of his posts said, "There's one way to love you but a thousand ways to kill you. I'm not going to rest until your body is a mess, soaked in blood, and dying from all the little cuts."

After his estranged wife got a restraining order, he wrote, "Put it in your pocket. Is it thick enough to stop a bullet?"

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Elonis was found guilty after the jury was instructed that the legal test was how his messages were perceived. In an 8-1 ruling, the court today said that was wrong.

The test, the court said, is what the sender means, not whether the recipient considers it a threat.

"Federal criminal liability generally does not turn solely on the results of an act without considering the defendant's mental state," Chief Justice Robert wrote.

There's no doubt, Roberts said, that the requirement of a guilty state of mind is satisfied "if the defendant transmits a communication for the purpose of issuing a threat, or with knowledge that the communication will be viewed as a threat."

Advocates for victims of domestic violence condemned the ruling and said the court failed to recognize how terrifying social media threats can be.

"Threats cause devastating harm to victims, including fear, anxiety, loss of sleep, and disruption, regardless of whether the abuser intended to threaten or only intended to vent or to make a joke," said Kim Gandy, president of the National Network to End Domestic Violence.

But civil liberties groups, including the ACLU, had urged the court to toss out the conviction.

"Today's decision properly recognizes that the law has for centuries required the government to prove criminal intent before putting someone in jail," said Steve Shapiro, the ACLU's national legal director. The ruling, he said, "is not a license to threaten, which remains illegal when properly proved."

Elonis was arrested in December 2010 and charged with violating a federal law that makes it a crime to transmit threats to injure someone else. He said he was kidding, imitating explicit rapper Eminem.

His lawyer argued that the legal test for a true threat should be the intent of the person making the statement. But the Obama administration argued that a message is illegal if a reasonable person would consider it threatening, regardless of what the sender intended.

Elonis's legal troubles are not over. He was arrested last week on domestic violence charges, accused of throwing a cooking pot at the mother of his current girlfriend.