A 13-year-old boy was caught with a gun at a Bronx school Thursday morning – after telling a friend he needed it because he was being bullied, law-enforcement sources told The Post. The boy brought the gun into Bronx Park Middle School on Wallace Avenue.

Clark said the student later pointed the weapon at several students off school property.

A spokeswoman for the Department of Education said police immediately responded and safely recovered the unloaded gun.

The boy was taken into custody at the school, which shares a building with the Bronx Green Middle School, cops said.

While the investigator spoke with the principal, the boy allegedly said that the firearm had “fallen into his backpack” from a shelf in his home, and “he didn’t know what to do with it”, the report stated.

The arrest came little more than a week after a two teens were stabbed – one fatally – inside a Bronx high school about two miles away.

Cedeno has been charged with murder and attempted murder.

In a jailhouse interview Friday, Cedeno said he was being constantly harassed for being bisexual and “just snapped” when he lunged at victims Matthew McCree and Ariane LaBoy, both 16, who had not tormented him before that day.

The Sept. 27 bloodshed, at a school that also did not have metal detectors, played out in front of a packed classroom of terrified students.