A 15-year-old Brooklyn boy playing with a gun accidentally shot himself in the chest, police said Saturday.

The boy was fooling around with the .25 caliber Raven pistol inside the fourth-floor apartment on Sterling Place and Rochester Avenue in Crown Heights at 4 a.m. Saturday when a bullet was accidentally discharged, police said.

It’s not clear yet how the teen got a hold of the gun, which was found on the building’s rooftop. Investigators were initially told the teen was shot after a robbery gone awry, sources said.

The boy is currently fighting for his life at Kings County Hospital.