(Reuters) - A Minnesota stalking law used to convict a high school student for insulting another teen on Twitter is overly broad and violates the U.S. Constitution’s First Amendment guarantee of free speech, the state Supreme Court ruled on Wednesday.

The teenager, on Twitter, used homophobic language against a schoolmate, suggested he kill himself by drinking bleach and mocked his autism, using a checkerboard of images with the boy’s face and a caption that read, “Click the Autistic Child,” according to court documents.

“Of course, First Amendment protections are not limitless,” Justice Paul Thissen wrote in a 41-page majority opinion.

“There is a point where First Amendment protections end and government regulation of speech or expressive conduct becomes permissible.”

The court can reverse a conviction, however, if it determines a law is “unconstitutionally overbroad on its face,” Thissen added.

The case follows efforts by the federal government and U.S. states to prevent cyber bullying, which has been linked to depression in youths.

But a number of court decisions in the last three years have limited the powers of prosecutors to charge people for cyber bullying. For instance, the North Carolina Supreme Court in 2016 overturned the cyber-bullying conviction of a man stemming from his online activity as a high school student. The court ruled the statute violated the First Amendment.

‘CRUEL AND EGREGIOUS’

“We fully acknowledge that bullying, stalking and other forms of harassment are serious problems in our society,” Thissen wrote.

The ruling did not deal with a Minnesota law which requires schools to prevent cyber bullying, which was not at issue in the case.

The case before the Minnesota Supreme Court involved a high school student identified only as A.J.B. who, in 2016, reacted to fellow student M.B.’s Twitter posts about girls by unleashing a series of 40 tweets against him.

“Essentially all of the tweets posted by A.J.B. and directed at M.B. contained cruel and egregious insults,” Thissen wrote in the opinion.

A.J.B. was prosecuted in juvenile court in Scott County and convicted of the criminal charges of stalking and harassment through electronic communication.

The Minnesota Supreme Court found the statute on stalking through electronic communication used to convict A.J.B. so broad that it could “prohibit and chill protected expression.” It overturned A.J.B.’s stalking conviction.

It ruled that a lower court could reconsider a separate criminal conviction of A.J.B. for harassment to determine whether he displayed an “intent to abuse.”