The US Supreme Court grappled on Monday with the thorny issue of how far the First Amendment stretches to protect offensive and frightening speech when the speaker claims his statements are meant in jest and delivered in the form of rap lyrics.

The case is potentially important because it could test the outer boundaries of First Amendment protection of threatening communications that put others in fear for their safety.

It is also important because it arises in the context of comments posted on Facebook. It provides the justices with their first opportunity to examine free speech issues that are increasingly arising in the fast-paced world of social media, where careless or malicious comments can achieve vast circulation in an instant.

The issue arises in the case of Pennsylvania man Anthony Elonis, who was convicted of writing a series of threatening posts on his Facebook page. The posts included menacing comments directed at his estranged wife and at an FBI agent who came to his home to investigate the Facebook posts.

Mr. Elonis maintains that his posts were protected speech because, as rap lyrics, they were artistic expression. He also argues that he never intended that his comments would be taken as an actual threat that would put others in fear for their lives.

The Facebook site included repeated notices that the content was strictly for entertainment and that the posts were not meant to pose a threat to anyone, Washington appellate lawyer John Elwood told the justices.

But some members of the court seemed skeptical.

“This sounds like a road map for threatening a spouse and getting away with it,” Justice Samuel Alito said.

The question in the case is when menacing comments cross the line separating free speech that is protected under the First Amendment from “true threats” that can be prosecuted as a crime.

Although the First Amendment protects a wide swath of speech, Americans are not free to say anything they like. For example, it is illegal to falsely yell “Fire!” in a crowded theater. It is illegal to make false, malicious statements about someone with the intent to harm their reputation. And Congress passed a law making it illegal to deliver “true threats” that place someone in fear.

Various free speech groups are siding with Elonis and urging the high court to establish a rigorous test of what qualifies as a “true threat” eligible for prosecution.

The Obama administration and groups seeking to protect domestic violence victims are urging the court to make it easier to prosecute those whose comments trigger fear.

Deputy Solicitor General Michael Dreeben said in his argument that Congress passed the threat law with the assumption that people would know the meaning of their own words and could be held accountable when their words caused fear or terror.

Mr. Dreeben dismissed arguments of opposing counsel that Elonis was merely writing therapeutic rap lyrics and posting disclaimers.

“He knows his wife is reading these posts,” Dreeben said.

Justice Elena Kagan expressed concern about the potential that such a broadly-enforced statute against “threats” might chill legitimate free speech.

“We typically say that the First Amendment requires a kind of buffer zone,” she said.

Dreeben responded that Elonis’s Facebook posts contained no First Amendment value. He said there was no evidence that enforcement of the statute in Elonis’s case would chill protected speech.

What about violent rap lyrics, such as those written and performed by rap stars like Eminem, Chief Justice John Roberts asked.

Dreeben said that context helps distinguish which statements constitute a true threat and thus warrant prosecution.

Violent rap lyrics performed by Eminem arise in the context of providing entertainment rather than in the context of an ongoing attempt to intimidate or frighten.

“If a jury concludes it is ambiguous, it must acquit,” Dreeben said.

The case stems from a series of major setbacks for Elonis in 2010 when his wife left him and took their children and then he lost his job at a Pennsylvania amusement park.

Elonis responded by lashing out at his estranged wife and his former employer in a series of posts on his Facebook page. Some of the posts were written as rap lyrics.

“There’s one way to love ya but a thousand ways to kill ya,” he wrote of his wife in October 2010. “And I’m not going to rest until your body is a mess....”

Elonis continued to write the lyrics after the wife was awarded custody of the children and a state court issued a restraining order against him.

In one post, Elonis included a link to a comedy routine in which the comedian jokes about how it is illegal to make statements about wanting to kill the president of the United States.

“Did you know that it’s illegal for me to say I want to kill my wife,” Elonis wrote.

“Now it was okay for me to say it right then because I was just telling you it’s illegal for me to say I want to kill my wife. I’m not actually saying it. I’m just letting you know that it’s illegal for me to say that.”

He then suggested that someone else might want to kill her by setting up a mortar in a cornfield near her home. He provided a map with a suggested launch site and a getaway route.

A week later Elonis asked his wife in another post if the court-issued protective order was “thick enough to stop a bullet.”

The posts terrified his wife and made her fearful for her safety and the safety of their children, according to government lawyers.

Elonis kept going. He posted that he wanted to make a name for himself by carrying out “the most heinous school shooting ever imagined.”

He added: “Hell hath no fury like a crazy man in a Kindergarten class.”

That post prompted a visit from the Federal Bureau of Investigation. Local police and the school superintendent were notified of the potential threat.

Elonis responded after the FBI visit with new lyrics suggesting that he wanted cut the female agent’s throat or detonate a suicide bomb and kill them both.

The statements caused the FBI agent to become fearful of her safety and the safety of her family, according to government lawyers.

Elonis was charged with making threatening communications. He was convicted and sentenced to nearly four years in federal prison. A federal appeals court upheld the conviction.

His lawyer, Mr. Elwood, argued that it isn’t enough to prove that the statements would cause a recipient to take the comment as a serious expression of an intent to harm or kill someone.

He said the government must also prove that Elonis intended to issue true threats, rather than merely display rap lyrics and mimic a comedy routine.

The case is Elonis v. US (13-198).

A decision is expected by June.