Aviation High School in Long Island City was locked down over the incident.
Authorities say another student saw the boy carrying what he thought was a weapon and notified school officials.
The school was searched and the student was taken into custody.
The weapon turned out to be a BB gun.
Charges are possible against the student, officials said.
The lockdown lasted for about 45 minutes.