The suspect allegedly approached the girl around 8:15 a.m. Monday at Oakdale Avenue and Keith Street as she was walking toward nearby Carver Elementary School, according to police.
Police said the man grabbed the girl from behind, put his hand over her mouth and said something about picking out young children as his victims.
The girl was able to break free and ran to safety inside the school, according to police.
The suspect fled and has not been found. He is described as a black man in his 30s with a heavy build, short, dreadlock-style braids and a scar on his upper right cheek. He was last seen wearing a blue shirt and blue jeans with a square-shaped earring in his left earlobe and a handkerchief covering part of his face, police said.
Anyone with information about the case is urged to call Inspector Vince Repetto from the Police Department's sexual assault detail at (415) 553-9117 or (415) 553-1361.
People wishing to remain anonymous can call the department's tip line at (415) 575-4444 or send a tip by text message to TIP411 with "SFPD" in the subject line.