New Brunswick, New Jersey - A former Rutgers University student was sentenced on Monday to 30 days in prison for bias crimes after he spied on his roommate's gay encounter in a case that drew national attention to bullying.

Dharun Ravi, 20, had faced a maximum of 10 years behind bars for his conviction for using a webcam to invade the privacy of his roommate, Tyler Clementi, and another man in their college dorm room.

Clementi, 18, committed suicide in September 2010, days after learning Ravi watched him through the computer-mounted camera and used social media to encourage others to do so. Ravi was not charged with causing Clementi's death.

Judge Glenn Berman sentenced him to 30 days in prison, followed by three years probation, 300 hours of community service as well as counseling about cyberbullying and alternative lifestyles.

He ordered Ravi to pay $10,000 for a community-based organization that assists victims of bias crimes and to pay $1,900 in penalties.

"I heard this jury say 'guilty' 288 times. Twenty-four questions, 12 jurors. That's the multiplication. I haven't heard you apologize once," Berman told Ravi.

"The person who described your conduct best is not here to describe your conduct. Tyler Clementi said your conduct was wildly inappropriate. I redacted that for the jury, but I didn't redact it for myself," the judge said.

The judge also pledged to recommend that Ravi, who was born in India and grew up in the United States, not be deported. A similar offer was made by the older man, identified only as M.B., in a letter his lawyer read in court before sentence was imposed.

The prosecution indicated it planned to appeal the judge's sentence, which would otherwise begin on May 31.

Additional reporting by Joseph Ax; Editing By Barbara Goldberg and Doina Chiacu