A Brooklyn student was taken into custody Thursday morning after he brought a BB gun and knife to school, police said.

The student was caught with the weapons shortly before 11 a.m. at the Rachel Carson High School for Coastal Studies on West Avenue and Shore Parkway in Coney Island.

He did not use either of the weapons, police said.

The school was placed on lockdown temporarily, the Department of Education said.

“Safety is our top priority and the NYPD swiftly and safely recovered the BB gun,” spokeswoman Miranda Barbot said. “Students and staff are safe and the temporary lockdown has been lifted.”

The school is about a block from where three teens were stabbed and three others were arrested in a fight outside the Abraham Lincoln High School on Tuesday, police said.