Updated

An 18-year-old student charged in a brutal California classroom hazing case that allegedly involved sex crimes reached a plea deal Monday and will testify against his teacher, prosecutors said.

Fernando Salgado agreed to plead guilty to one count each of attempted sexual penetration by a foreign object and assault with a deadly weapon, said Christopher Lee, a spokesman for the San Bernardino County district attorney's office.

If he testifies truthfully against his teacher, 27-year-old Emmanuel De La Rosa, the sex count would be dropped under the agreement.

Superior Court Judge Douglas A. Fettel stayed Salgado's sentence of three years of felony probation and 180 days in county jail in exchange for his testimony. The teen could have faced four years in prison if convicted of both charges, Lee said.

Salgado's public defender, Isaac Rees, did not immediately return a call for comment.

Authorities have been tight-lipped about the case but say three boys were attacked in separate incidents in De La Rosa's summer school masonry class. A total of five people -- including three minors -- were arrested in the investigation.

Students in the class at A.B. Miller High School were assaulted to maintain order, and De La Rosa became aware of what the assailants were doing and may have in one instance directed them to do it, Fontana police have said.

De La Rosa has pleaded not guilty to five felony counts, including attempted sexual penetration with a foreign object and false imprisonment. De La Rosa's attorney, Grover Porter, did not return a call seeking comment.

The trained bricklayer was replaced by a school administrator in the last week of the five-week summer class, and counselors were made available to students.

Fontana is located about 55 miles northeast of Los Angeles.