San Mateo County prosecutors were denied Friday morning in their bid to dismiss a judge from a sex case involving a former elementary school teacher for fear he would hand out a lenient sentence.

However, their fears were erased when Judge Donald Ayoob offered the former teacher at St. Matthew’s Episcopal Day School in San Mateo a prison term ranging from three years, eight months to eight years.

The teacher, Anthony Satriano, pleaded no contest to five felony counts, including child molestation, attempted child molestation and three counts of using a minor for sex acts, according to the San Mateo County District Attorney’s Office. Satriano, 33, is scheduled to be sentenced by Ayoob on Feb. 23.

“He told the defendant his sentence will be somewhere in that range,” said San Mateo County District Attorney Steve Wagstaffe. “We were satisfied with that.”

Prosecutors allege Satriano took photos of five different girls, ages 5 and 6, during one-on-one interaction with them. When he was arrested, police found images of the girls on Satriano’s cellphone, including some posed in “lewd positions,” according to prosecutors.

Parents of the five girls who were victims in the case will be allowed to address Ayoob before the sentencing, Wagstaffe said. Satriano is expected to have people speak on his behalf as well, according to his attorney Steven Chase.

Prosecutors asked Ayoob for a possible maximum sentence of eight years, which he agreed to, Wagstaffe said. The minimum sentence will be three years, eight months in state prison, Chase said.

Satriano also will have to register as a sex offender.

Chase believes Satriano should serve time in county jail, not prison. Chase argued that Satriano has never been in trouble, had no prior complaints against him during his employment working with kids and, in this case, “never touched these children in a lewd manner.”

“His actions had to to with what was lewd to him,” Chase said. “The children were oblivious to what was going on. The intrusion to the children was very slight.”

Although Chase argued for probation, he described as Ayoob an incredibly fair judge who “considers both the victim and defendant.” In this case, Ayoob felt because Satriano had exploited children, a prison term was appropriate, Chase said.

“In my eyes, he’s the best judge we have in the courthouse, in terms of his fairness to both sides and his openness to listen and decide,” Chase said. “He does what he thinks is right.”

San Mateo County Chief Deputy District Attorney Karen Guidotti previously told this newspaper prosecutors were concerned Ayoob would “not deem this case (Satriano) as serious as we believe it is.”

“Our concern formed from his sentencing in other matters,” Guidotti said.

Guidotti cited Ayoob’s record — including his decision in November to sentence a man who possessed 14,000 images and 50 videos of children as young as 9 engaging in sex acts to a full year in county jail — rather than the two years in state prison the prosecution wanted.

Friday morning, Presiding Judge Susan Etezadi denied the prosecution’s case to remove Ayoob. That afternoon, Satriano pleaded no contest in front of Ayoob.

Satriano, who worked with children between the ages of 5 and 8 in the preschool and after-school care program, was arrested in April by San Mateo police. Satriano asked the girls to put on certain clothing and then posed them in such a way he found provocative, according to Wagstaffe.

Staff writer Tracey Kaplan contributed to this report.