NEW YORK — New York City police confiscated a loaded gun from a student on the first day of school Thursday.

The gun set off the metal detector alarm at the Brooklyn School for Career Development, police said. Security agents surrounded him and discovered a loaded .22-caliber pistol in his bag.

No one was injured. Charges were pending against the student, who was not identified.

Claudia Jones, 31, was standing in line to get into the school with her daughter. She told the Daily News she heard the metal detectors beeping.

“I didn’t think nothing of it. I thought it was something else. They just told us you got to be out. He has a gun. You got to leave,” Jones said.

She said they put the teen to the ground and handcuffed him.

“It was scary,” Jones said. “I don’t know why he would bring a gun to school knowing they have metal detectors.”

A spokeswoman for the city Department of Education said the incident is “deeply troubling.” There is “zero tolerance” for weapons in schools, she said.

Mayor Bill de Blasio told reporters at a school visit in Staten Island the city was reviewing the use of metal detectors in public schools

Thursday was the first day of school for most of the city’s 1.1 million public school pupils.

The Brooklyn School for Career Development serves 246 students in grades 9 through 12.