(Jose Luis Magana/AP)

Lester Gerard Packingham praised Jesus on his Facebook page and simultaneously committed a felony. But his conviction may not stand for long.

A majority of the Supreme Court on Monday seemed prepared to strike down a North Carolina law that makes it a crime for a registered sex offender such as Packingham to access social media sites even years after they have served their sentences or completed probation.

Packingham, then 21, pleaded guilty 15 years ago to having sex with a 13-year-old and received a suspended sentence. But in 2010, he violated the state’s social media prohibition by posting a jubilant Facebook message about escaping punishment in traffic court.

“Man God is Good! How about I got so much favor they dismissed the ticket before court even started? . . . Praise be to GOD, WOW! Thanks JESUS!”

Justice Elena Kagan was perhaps the most outspoken of the justices who indicated North Carolina had gone so far in restricting sex offenders’ use of the Internet that the state was violating First Amendment rights.

Everyone knows that the president communicates via Twitter, she said, but so do all 50 governors, and members of Congress maintain accounts or Facebook pages as a way to connect with their constituents, she said.

“So whether it’s political community, whether it’s religious community, I mean, these sites have become embedded in our culture as ways to communicate and ways to exercise our constitutional rights, haven’t they?” Kagan asked North Carolina Deputy Attorney General Robert C. Montgomery, who was defending the law.

Montgomery agreed they had, but said the state wasn’t restricting everything.

“This is a part of the Internet, but it’s not the entire Internet that is being taken away from these offenders,” Montgomery said. “They can still have their own blog. They can read blogs. They can do podcasts.”

Montgomery said people who have been convicted could also access news media sites, but there was a lively dispute about whether the law was so broad that even that was forbidden.

Even if specific news organizations are not off-limits, said Justice Ruth Bader Ginsburg, “the point is that these people are being cut off from a very large part of the marketplace of ideas. And the First Amendment includes not only the right to speak, but the right to receive information.”

After Packingham pleaded guilty to the 2002 offense, he received the lightest possible sentence — 10 to 12 months — which was then suspended. He did two years of supervised probation.

A Durham police officer searching Facebook for registered sex offenders saw Packingham’s posting about the traffic ticket. He was charged with violating the state law and convicted. Again, he received a suspended sentence.

One court agreed with Packingham that the law violated the First Amendment. But the North Carolina Supreme Court reversed the decision.

Montgomery on Monday told the justices that if the state can keep sex offenders away from parks, schools and other places where children congregate, it could also keep them away from “virtual places where children congregate online; specifically, commercial social networking websites.”

But Packingham’s lawyer, Stanford law professor David T. Goldberg, told the justices Monday that the North Carolina law covers “vast swaths of core First Amendment activity that is totally unrelated to the government’s preventative purpose.”

Goldberg said his client “is not accused of communicating with or viewing the profile of a minor.” Instead, he violated the law “by speaking to his friends and family about his experience in traffic court.”

Under mild questioning by the justices, Goldberg acknowledged it would be difficult for law enforcement to monitor Packingham to make sure he was not communicating with minors, and that it probably would be lawful for an Internet ban to be imposed as a condition of parole.

Justice Samuel A. Alito Jr. reminded Goldberg that there were “alternative channels” available to Packingham. “Now, I know there are people who think that life is not possible without Twitter and Facebook and these things and that 2003 was the dark ages,” he said to laughter in the courtroom.

But Montgomery got the toughest questions. Justice Stephen G. Breyer ran through the checklist of how the court considers government action that affects speech: “The state has a reason? Yeah, it does. Does it limit free speech? Dramatically. Are there other, less restrictive ways of doing it? We’re not sure, but we think probably. . . . Okay. End of case, right?”

Montgomery noted that the court in the past has approved broad restrictions on speech, such as prohibiting politicking within 100 feet of a polling place.

But Kagan responded, “that is like one out of a zillion First Amendment cases that we’ve decided in our history.”

And Justice Anthony M. Kennedy told Montgomery that if that is the best precedent on his side, “I think you lose.”

The case is Packingham v. North Carolina.