New York City Police Department spokesman John Grimpel said authorities are investigating how the unloaded .22-caliber handgun ended up in the child's backpack.
Police also found an ammunition clip and a flare gun in the bag belonging to the second-grade student, Grimpel said.
Officials locked down the Wave Preparatory Elementary School, located in Queens, for an hour, the New York City Education Department said.
In December a gunman killed 20 first-graders along with six adults at Sandy Hook Elementary School in Newtown, Connecticut.
On Wednesday President Barack Obama launched the biggest U.S. gun-control push in generations, urging Congress to approve an assault weapons ban and background checks for all gun buyers to prevent mass shootings like the Newtown massacre.
© Thomson Reuters 2013