He arrived at the Urban Assembly School for Law and Justice on Adams Street just before noon with the firearm in his bag, officials say.
A school secretary saw the weapon and told the dean who alerted school safety agents. They restrained the student and took him into custody.
Charges against him are pending.
The weapon, which appears to be a ghost gun with no markings, and bullets were recovered.
The teen also had about $30,000 cash.
The Department of Education released the following statement:
"Dangerous items of any kind have absolutely no place in our schools, and our outstanding school staff and School Safety Agents immediately and safely recovered this item shortly after the student entered the school building, ensuring that all students and staff are safe. All protocols were followed, and we are working closely with NYPD regarding follow-up actions."
ALSO READ | Cops explain how new DNA technology led to arrest in 1999 cold case
* More Brooklyn news
* Send us a news tip
* Download the abc7NY app for breaking news alerts
* Follow us on YouTube
Submit a News Tip