By Amy Tennery

NEW YORK (Reuters) - A U.S. appeals court on Friday upheld the conviction of a Pennsylvania man who made threatening statements toward his then-wife and others on Facebook, in a case that probed the boundaries of freedom of speech on social media.

Anthony Elonis wrote Facebook posts in 2010 that discussed killing a Federal Bureau of Investigation agent and killing his estranged wife, but claimed the posts were song lyrics and not threats.

He was convicted of sending threatening communications and served 44 months in prison. The Supreme Court in June 2015 threw out the conviction, arguing that the jury in his trial had not been properly instructed. (http://reut.rs/2ejBlCB)

But the United States Court of Appeals for the Third Circuit said in its ruling on Friday that the error was harmless because the jury would have come to the same conclusion if properly instructed.

Elonis' attorney Abraham Rein said he and his client were reviewing their options.

"Naturally we are disappointed with the ruling," Rein said.

'A THOUSAND WAYS TO KILL YOU'

The ruling comes amid renewed controversy over what content is acceptable to post on social media.

In July 2016, a Kentucky man was arrested after he wrote a Facebook post in which he said "I will stand up and put a bullet in a cops head if others will join me," local media reported.

Prosecutors said Elonis' posts were not mere entertainment, as he had claimed, but rather showed intent to threaten others.

"There’s one way to love you but a thousand ways to kill you," Elonis wrote in one October 2010 post. "I’m not going to rest until your body is a mess, soaked in blood and dying from all the little cuts."

In another, Elonis described committing a school shooting.

"Enough elementary schools in a ten mile radius to initiate the most heinous school shooting ever imagined," he wrote in a November 2010 post. "And hell hath no fury like a crazy man in a kindergarten class."

(Reporting by Amy Tennery; Editing by Lisa Shumaker)