A quick-thinking college student scared off a sexual deviant who broke into her New York dorm and exposed himself to her by pretending she had a developmental disorder, prosecutors say.

Ariel Caro, 32, was sentenced Tuesday to two and a half years in state prison on charges of first degree attempted sex abuse and second degree attempted burglary as a sexually motivated crime for the incident last year at Pace University’s Pleasantville campus.

UTAH MAN, 22, GETS LIFE WITHOUT PAROLE FOR RAPE, MURDER OF 5-YEAR-OLD NIECE

The unidentified student reportedly heard knocking on her dorm room door on Sept. 11, 2018 at around 7:30 p.m. and, thinking it was someone else, she opened the door only to find Caro — who pushed his way in. Caro then closed the door behind him and began masturbating in front of her.

Fearing what might happen next, the student began to mimic the behavior of an autistic person that “she had seen on television,” the Westchester County District Attorney’s Office said in a news release.

“Using her wits, the student began to repeat a series of expressions, acting, she said, as if she suffered from a form of autism, as she had seen on television. As she got louder, he chose to flee,” the DA’s office said.

CALIFORNIA HIGH SCHOOL PSYCHOLOGIST ALLEGEDLY HAD SEX WITH STUDENT IN CLASSROOM, OFFICIALS SAY

Once Caro, a New York City resident, fled the scene, the girl contacted her mother, who then called campus security.

Investigators discovered not only that Caro was not a student, but he had also broken into a vacant dorm and placed his “possessions and drug paraphernalia” inside.

A victim statement from the student read in court this week detailed her struggles following the incident.

CLICK HERE TO GET THE FOX NEWS APP

“I wondered whether my life ambition of going to university was misplaced and thought about dropping out of college," the statement noted, "but realized that this would only harm me further…I hope one day I will feel safe again and not so helpless, a feeling I never had before this horrible attack."

In addition to jail time, Caro will also have to register as a sex offender and will be subject to 10 years supervision following his release.