A California man with HIV sexually assaulted a 15-year-old girl after posing as a police officer and pretending to arrest her for jaywalking, prosecutors said.

Joseph Kenneth Cornett, 41, captured the girl on her way home from school in Lancaster at 3 p.m. Wednesday, the Los Angeles District Attorney’s Office said.

He took her to an abandoned mobile classroom and tried to rape her before the girl escaped, prosecutors said.

She ran to a parent leaving the Lancaster Baptist Church across the street and asked for help, CBS Los Angeles reported.

Good Samaritans chased after Cornett but could not catch him, witnesses said. He ran to his car, which got stuck in sand, allowing police to apprehend him.

Cornett, who was already on probation, was put in restraints and a face mask because he spit and fought with officers, prosecutors said.

He pleaded not guilty Monday to nine felonies, including attempting to have unprotected sexual activity by one who knows he is infected by HIV, prosecutors said.