Dharun Ravi, a former Rutgers University student who used a webcam to spy on his gay roommate was sentenced on Monday to just 30 days in jail — a punishment that disappointed some activists but came as a relief to others who feared he would be made a scapegoat for his fellow freshman’s suicide.

Dharun Ravi, 20, could have gotten 10 years behind bars for his part in a case that burst onto front pages when Tyler Clementi threw himself to his death off the George Washinton Bridge.

Instead, Superior Court Judge Glenn Berman gave Ravi a month in jail, placed him on three years’ probation, ordered him to get counseling and pay $10,000 toward a program to help victims of hate crimes.

“Our society has every right to expect zero tolerance for intolerance,” the judge said.

Prosecutor Bruce Kaplan said he will appeal the sentence, calling it insufficient.

The tear-filled sentencing touched on many of the issues that made the case heart-wrenching and legally complicated: anti-gay bullying, teen suicide, hate-crime laws in the fast-changing Internet age, and the uses and abuses of technology in the hands of young people.

Ravi did not speak in court but shed tears as his mother pleaded with the judge not to send him to prison. Afterward, Ravi, his family and his lawyers left court without comment. He is expected to appeal his conviction.

In handing down the sentence, the judge quoted an email from Clementi himself describing Ravi’s conduct as “wildly inappropriate.”

At the same time, Berman pointed out that Ravi was not charged in Clementi’s suicide. He said Ravi has spent 20 months in “exile” since his arrest. And he suggested “hate crime” is a misnomer for what Ravi was convicted of: “I do not believe he hated Tyler Clementi.”

He also said he has examined the bias intimidation laws in 39 states and found that New Jersey’s is among the broadest. Most, he said, are used only to increase the sentences of people convicted of violent crimes.

The judge said he would recommend Ravi not be deported to his native India. Deportation is still a possibility, but a sentence of a year or more would have been more likely to trigger it.

Prosecutors had asked that Ravi be sent to prison; they did not say how much time he should get other than that it did not have to be the maximum. If prosecutors appeal the sentence, Ravi may not have to report to jail on May 31 as ordered.

New Jersey gay rights organization Garden State Equality expressed disappointment with the punishment. In a statement, chairman Steven Goldstein suggested that while the maximum would have been an act of “vengeance,” 30 days was too light.

“This was not merely a childhood prank gone awry,” Goldstein said.

Bill Dobbs, a New York gay rights activist who has long argued that hate-crime laws can be dangerous, said he believes the judge gave a short sentence in part in response to a backlash against the prosecution that became visible in recent weeks, including at a rally last week at New Jersey’s Statehouse, where hundreds of people called for leniency.

“Law and order cannot solve social problems,” he said. “If you put too much pressure on one person, you can crush someone on the receiving end.”

Marc Poirier, a professor at Seton Hall Law School, said the judge skillfully found a middle ground. “Having no jail time would have been interpreted as being a slap on the wrist,” he said. And a sentence of five to 10 years would be “out of control.”

The case began in September 2010, when Ravi’s randomly assigned roommate asked Ravi for the dorm room alone so that he and a guest could have privacy. Ravi went to a friend’s room, and they used a computer to watch Clementi and another man kissing.

They told others about it through instant messages and tweets, with Ravi boasting: “I saw him making out with a dude. Yay.”

When Clementi asked for privacy again two days later, Ravi agreed, then told friends how to access his webcam. But this time, the camera was not on when the guest came over. There was testimony both that Clementi unplugged it and that Ravi himself put it to sleep.

The next night, Clementi — who learned he had been spied on — committed suicide at age 18, leaving behind a final Facebook update: “jumping off the gw bridge, sorry.”

Gay-rights activists held up Clementi as an example of the consequences of bullying gays. President Barack Obama himself weighed in on the tragedy.

Ravi was convicted in March of invasion of privacy, bias intimidation on the basis of sexual orientation — an offense widely referred to as a hate crime — and trying to cover his tracks by destroying text messages and tweets and tampering with a witness.

As for Clementi’s suicide, his mother Jane Clementi told the judge she didn’t know exactly why her son killed himself. And Ravi’s lawyers argued that the trial was not fair because the judge did not give them details from Clementi’s computer that may have explained it.

Ravi is being “demonized by the gay community, and they’re associating whatever he did with the death of Tyler,” said lawyer Steven Altman.

Tyler’s father Joe Clementi told the judge that Ravi deserved to be punished, saying the young man saw his son as undeserving of basic human decency. The elder Clementi said Ravi “still does not get it” and has no remorse.

Dharun’s mother Sabitha Ravi said in court that her son “doesn’t have any hatred in his heart toward anybody.”

“Dharun’s dreams are shattered and he has been living in hell for the past 20 months,” she said through tears, recounting how he has lost more than 20 pounds from an already-thin frame and how he only finds comfort with his little brother and his dog.

Before the trial prosecutors had offered Ravi a plea bargain that called for no prison time. He turned it down, having stated that he was not guilty of the charges brought against him.