SARATOGA — A former night monitor at the popular Walden West science camp pleaded no contest to over a dozen felony charges that he sexually abused two campers and distributed child pornography, in a case that evoked broad criticism over background checks and how authorities belatedly alerted parents to the danger lurking around their children.

Under a negotiated settlement with the Santa Clara County District Attorney’s Office, 29-year-old Edgar Covarrubias-Padilla will be sentenced to 18 years in prison when he returns to court May 25.

“A person who molested two children and distributed child pornography, exploiting more children, will be sentenced to almost two decades in prison,” deputy district attorney David Shabaglian said in a statement. “Our community is safer because of that.”

His no-contest plea Thursday to 14 felony counts and one misdemeanor related to the child porn and molestation charges has the same legal effect as a conviction. The accusations first surfaced in May 2015 when he was arrested for having child pornography, which was soon followed by a 10-year-old Santa Clara County boy telling authorities he had been fondled by Covarrubias-Padilla at the Saratoga camp a month earlier. Later that summer, after the news had spread, a boy from Stanislaus County came forward to report that the defendant molested him at the camp when he was between 7 and 9 years old.

Covarrubias-Padilla was known as “Papa Bear” at the camp, where he was a live-in staffer. Investigators would later learn that he was distributing child pornography under the email handle “pbear.” Authorities found more than 20,000 pornographic images and videos of children on his laptop, cellphone and cloud accounts.

Reading this on your phone? Stay up to date with our new, free mobile app. Get it from the Apple app store or the Google Play store.

Besides the crimes for which he was convicted, Covarrubias-Padilla’s case spurred controversy after the revelation that he was suspected for several months of child-porn activity by the Department of Homeland Security, but the agency did not notify local officials and authorities until after Covarrubias-Padilla had molested his most recent victim.

The defendant’s immigration status also was a point of controversy: The camp manager was granted a work permit under a federal program for immigrants brought to the United States illegally as children, and critics lambasted federal officials for not sufficiently monitoring him.

Reading this on your phone or tablet? Stay up to date on Bay Area and Silicon Valley news with our new, free mobile app. Get it from the Apple app store or the Google Play store.

The Santa Clara County Office of Education, which oversees the camp, caught its share of criticism in the wake of Covarrubias-Padilla’s arrest, first when it infamously assured parents that he had no contact with children, which was swiftly proven false and precipitated the eventual departure of the camp’s director at the time.

It also surfaced that a decade earlier, another live-in staffer was convicted of molesting a child he met online and that the case did not spark any public alerts or a revamping of safeguards or background checks. Covarrubias-Padilla also exaggerated his work history and his references were never checked, and a few months after his August 2013 hiring he became night supervisor, serving as the only adult on duty at night overseeing dozens of elementary-school children.

Those oversights prompted the office to form a task force to recommend safeguards to better protect the camp’s students and vet prospective employees. Among the adopted measures were a “Rule of 3” that mandates a third person be present whenever a child is with an adult, increased overnight staffing, a student buddy system for going to the bathroom, and the ending of wake-up practices in which staff members walked through cabins of sleeping children.

Officials with the agency said they were glad to see the resolution of the case.

“The Santa Clara County Office of Education has fully cooperated with law enforcement in this investigation and we have continuously monitored the court proceedings since Mr. Covarrubias was arrested,” County Superintendent Jon R. Gundry said in a statement. “We are pleased that the criminal charges have been resolved without a lengthy trial that would have been very stressful for children and families involved with the case.”