By Lawrence Hurley

WASHINGTON (Reuters) - The U.S. Supreme Court on Monday threw out the conviction of a Pennsylvania man who made threatening Facebook statements toward his estranged wife and others in a ruling that makes it tougher to prosecute people for using menacing language on social media.

The court ruled 8-1 in favor of Anthony Elonis in a case that explored the boundaries of free speech online.

The justices decided Elonis could not be convicted merely on the basis that a reasonable person might consider his comments threatening. The court instead said prosecution would be allowed under the federal law that he was accused of breaking only if Elonis himself intended his words as threats.

Elonis wrote the Facebook posts in 2010, when he was 27, after his wife left him. Written in the form of rap lyrics, he fantasized about killing her, knifing a female FBI agent and shooting schoolchildren. After a court granted his wife a protective order against him, Elonis posted: "Is it thick enough to stop a bullet?"

They are now divorced.

Seven justices voted to throw out his conviction, while Justice Samuel Alito said he would have sent the case back to an appeals court to decide.

"We're pleased that the Supreme Court saw the case for what it was: an unprecedented criminal conviction for a 'crime' of pure speech based on only a showing of negligence," said Elonis' lawyer, John Elwood.

Elonis is back in jail in Pennsylvania on unrelated assault charges. Local media reported he was arrested after throwing a pot at a woman.

The case touched upon the rise of social media and how people use it to express strongly held feelings.

Elonis' lawyers argued his statements were little different from lyrics by performers like rapper Eminem and were meant as art or a form of therapy.

Another of his Facebook posts recounted a visit by an FBI agent in which he imagined murdering her: "Pull my knife, flick my wrist, and slit her throat/ Leave her bleedin’ from her jugular in the arms of her partner."

The court's legal reasoning did not rest on free speech, instead focusing on Elonis' intent.

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

Lower courts had said Elonis could be held responsible regardless of whether he believed his messages could be viewed as threatening.

'LEFT TO GUESS'

In a separate opinion concurring in the judgment but not the rationale, Alito criticized the majority's legal reasoning, saying "attorneys and judges are left to guess" what level of intent is required for a conviction to stick.

Justice Clarence Thomas was the only justice who would have upheld the conviction outright. Thomas said the decision "throws everyone from appellate judges to everyday Facebook users into a state of uncertainty."

The National Center for Victims of Crime, which filed court papers siding against Elonis, said the ruling will sow confusion.

"The laws governing social media require swift interpretation to keep pace with the ever-advancing criminal activity in this space. The justices today missed the opportunity to define the law and left the victims of this case and others in jeopardy," said Mai Fernandez, the group's executive director.

Civil liberties advocates praised the ruling.

"Today's decision properly recognizes that the law has for centuries required the government to prove criminal intent before putting someone in jail," said Steven Shapiro, national legal director of the American Civil Liberties Union, which filed court papers backing Elonis.

"That principle is especially important when a prosecution is based on a defendant's words. The Internet does not change this long-standing rule," Shapiro added.

Elonis was convicted of violating a federal law that outlaws sending a threatening communication and was sentenced to 44 months in prison. In 2013, the Philadelphia-based 3rd U.S. Circuit Court of Appeals upheld the conviction.

The case is Elonis v. USA, U.S. Supreme Court, 13-983.

(Editing by Will Dunham)