The Supreme Court on Monday struck down a state law limiting access for registered sex offenders to websites like Facebook.

The North Carolina law had made it a felony to log onto certain sites that are "known" to allow minors to access. Under that law, convicted sex offender Lester Packingham was arrested after police noticed a 2010 Facebook posting celebrating the dismissal of a traffic ticket.

In the majority opinion on Monday, Justice Anthony Kennedy concluded, “It is well established that, as a general rule, the Government ‘may not suppress lawful speech as the means to suppress unlawful speech.’ That is what North Carolina has done here. Its law must be held invalid.”

Packingham was prosecuted, convicted of a felony and received a suspended prison sentence. His lawyers, though, said no evidence pointed to Packingham using Facebook or his computer to communicate with minors or that he posted anything inappropriate or obscene.

In the court’s majority opinion, Kennedy wrote that to “foreclose access to social media altogether is to prevent the user from engaging in the legitimate exercise of First Amendment rights.”

He wrote, “Even convicted criminals—and in some instances especially convicted criminals—might receive legitimate benefits from these means for access to the world of ideas, in particular if they seek to reform and to pursue lawful and rewarding lives.”

Three conservative Justices—John Roberts, Samuel Alito and Clarence Thomas—agreed that the law violates free speech, but said Kennedy’s opinion went too far in suggesting states have a very limited role in restricting unlimited Internet access from “dangerous sexual predators.”

Fox News’ Bill Mears and The Associated Press contributed to this report.