David Velasquez, 19, was arrested after the attack, which occurred at about 5:15 p.m. Monday in a parking garage at Summit Preparatory Charter High School, located at 890 Broadway, Redwood City police Sgt. Sean Hart said.
The attacker came out of some bushes near the parking lot and grabbed the teacher from behind, put a knife to her side and ordered her to walk to her car, Assistant District Attorney Al Serrato said.
The suspect said he would kill the teacher if she didn't do what she was told, according to the district attorney's office.
Serrato said the teacher allegedly recognized Velasquez' voice and intentionally dropped her keys to delay him.
The attacker then pushed the woman to the ground and tried to pry her legs apart with his elbow, prosecutors said.
Another teacher entered the garage and screamed at the man, and he got up and ran away.
Velasquez was taken into custody later that evening, police said.
He has been charged with assault with intent to commit rape, kidnapping with intent to rape, false imprisonment and making criminal threats.
Velasquez made his first court appearance in the case on Wednesday and is scheduled to return to court to enter a plea on Feb. 8.