TRENTON, N.J. — A former Rutgers University freshman who prosecutors said used a webcam to spy on his roommate’s same-sex encounter was charged Wednesday with a hate crime and accused of deleting tweets and texts to cover up his tracks.

Dharun Ravi, 19, was indicted in Middlesex County on 15 counts including bias intimidation and invasion of privacy in events that predated the suicide of 18-year-old Tyler Clementi, who in death started a national conversation on the perils of bullying.

Ravi already had faced invasion of privacy charges along with another Rutgers student, Molly Wei. It took prosecutors months to present their case to a grand jury alleging that Ravi targeted Clementi because of his sexual orientation and tried to broadcast the encounter online to intimidate his roommate.

The cascade of events started the day Ravi “learned the name of his roommate,” Middlesex County Prosecutor Bruce Kaplan said in a statement, not elaborating. The charges do not link the alleged spying to Clementi’s suicide.

“The grand jury indictment spells out cold and calculated acts against our son, Tyler, by his former college roommate,” Clementi’s parents, Jane and Joe Clementi, said in a statement. “If these facts are true, as they appear to be, then it is important for our criminal justice system to establish clear accountability under the law.”

The indictment is an important step in a heartbreaking case, state Attorney General Paula Dow said.

If convicted of the most serious bias charge, Ravi could face five to 10 years in prison.

Kaplan said charges against Wei weren’t presented to the grand jury. It was unclear Wednesday whether a case against Wei would go before a grand jury or whether she helped prosecutors in the case against Ravi.

An attorney for Ravi did not return a call seeking comment, and Wei’s attorney declined to comment.

Prosecutors have said that Ravi used Wei’s computer in her dorm room to activate a webcam on a computer in his room to view and stream Clementi’s encounter.