LOS ANGELES — The Los Angeles Unified School District will pay $139 million to end remaining litigation involving an elementary school teacher convicted of committing numerous lewd acts on his students, according to the settlement announced Friday.

The deal involving 81 students puts a legal end to the saga that began when Miramonte Elementary School teacher Mark Berndt was arrested in 2012 and accused of blindfolding students and feeding them his semen on spoons and cookies.

Plaintiff’s lawyers had planned to present evidence that the school district was aware of sexual misconduct by Berndt over three decades but failed to act until a photo processor at a CVS pharmacy contacted police about pictures of blindfolded children being fed some substance.

The 19-year-old woman had been on the job at CVS for only a month when she discovered the troubling photos and learned Berndt had been processing similar pictures there since 2005, said John Manly, one of the attorneys who filed the lawsuit.

“She was told not to call the police by her supervisors and she did it anyway,” Manly said. “If she hadn’t made that call, we wouldn’t be here today and he’d still be teaching.”

The investigation caused a huge upheaval at the school, where most of the students are from poor Hispanic homes. Parents had been hesitant to complain about Berndt because of a deep respect for teachers, and they were reluctant to cooperate with police because many feared deportation.

Berndt was sentenced to 25 years in prison after pleading no contest to 23 counts of lewd conduct.

He retired from teaching after his arrest.