In response, the boy, who was sitting on the couch and playing with a BB gun, held up the gun at the suspect and his accomplices, police spokeswoman Liz Wylie said.
The boy's action caused all three suspects to scurry off. Nothing was taken from the apartment complex and no one was harmed, Wylie said.
The incident at the apartment complex in the 200 block of Ortega Avenue unfolded around 10:50 p.m. on Wednesday, Wylie said.
The boy and his friend, also 15, were sitting in the apartment's living room. The boy was playing with a BB gun and his friend was sitting at a desk using the computer when the friend's 43-year-old father opened the front door.
Wylie said just as he was opening the door, the man heard footsteps behind him. As he stepped inside the living room, a man grabbed him from behind in a chokehold and pointed a gun to his head, she said.
The father grabbed the gun and tried to yank it out of the suspect's hand. Meanwhile, the victim's son sprang into action and went to help his father, but the suspect regained control of the gun and pointed it at the son who was standing two feet away, Wylie said.
At the same time, two additional suspects came up behind the father and started searching his pockets.
That is when the 15-year-old boy grabbed the BB gun, drew the slide back and released it, which Wylie said, "makes a sound as if he put a round in the chamber."
He pointed the BB gun at the suspects, causing them to flee. They remain at-large, Wylie said.
The suspects were described as males in their late teens, of average height, wearing black clothing from head to toe. The gunman was described as being skinny.
Anyone with information about the attempted robbery is asked to call the Police Department at (650) 903-6344.