A woman was assaulted in the Pacific Heights area on Sunday, police Sgt. Danielle Newman said.
The 36-year-old victim was confronted by the suspect as she exited her vehicle in front of her residence in the 2600 block of Sacramento Street about 3:55 p.m., police said.
The suspect pinned the victim against a tree and then tackled her as she tried to get away, police said. A passerby tried to intervene and the suspect pulled out a knife and fled.
The suspect returned to the victim's residence and kicked the front door, police said. Neighbors reported seeing the suspect on the building's roof, after having gained access somehow.
He was subsequently arrested inside the victim's apartment.
He was identified as 18-year-old San Francisco resident Victor Manuel Rodriguez, Newman said. He was booked on charges aggravated assault with a knife, burglary, false imprisonment, felony vandalism, misdemeanor vandalism, stalking and resisting arrest.
Rodriguez and the victim are known to each other, Newman said.