The victim was lying in bed at his home in the 400 block of Railroad Avenue when the suspect came through his bedroom window at about 12:40 a.m., police said.
The intruder, who the victim believes is a friend of his brother, held the stun gun to the victim's neck and threatened to hurt his family if he told police, investigators said.
The victim fought back and was stunned in the hand during the struggle, police said.
The suspect eventually ran out of the home through the front door without taking any property, and dropped the stun gun on the floor while fleeing, police said.
Police believe they have identified the suspect. Anyone with information on the case is asked to call South San Francisco police at (650) 877-8900.