The suspect has been identified as Mohammad Khaliqi. Police arrested Khaliqi in the 1400 block of School St. in San Leandro on Friday afternoon.
He's facing multiple counts of burglary, attempted sexual assault and false imprisonment.
On Tuesday, the man followed the girl as she walked home from school. Police responded to the girl's home in the 4000 block of Rio Vista Avenue and she told investigators he had forced his way through the front door of her home as she went inside. She fought him off and he fled before police arrived.
The girl then locked the door after he left, hid in a closet and texted her father: "DADDY COME HOME NOW. SOME GUY TRIED TO RAPE ME."
The attack was caught on the family's home surveillance system.
"The guy starts a conversation with her and when she opens up the door, the suspect pushes her in, tries to sexually assault her as well. The little girl is brave, she fights back, and the guy leaves on foot," San Jose Police Sgt. Enrique Garcia said. "He's not concerned about being caught, since he's doing this in broad daylight."
On April 2, the same suspect is believed to have followed a 28-year-old woman into a public restroom at Mitsuwa Marketplace, a Japanese grocery store at 675 Saratoga Ave.
He attempted to sexually assault the woman in the restroom and fled before police arrived shortly before 1 p.m.
PHOTOS: SJ police say girl attacked by predator at home
Police released surveillance photos of the man from both locations.
Anyone with information on these incidents or any other unreported incident is asked to contact the Police Department's Sexual Assault Investigations Unit at 408-277-4102.