Police have identified the suspect as 33-year-old Michael Thomas.
Investigators say he threatened to kill four people near B and Stanislaus Streets in downtown Fresno around 10:30 am.
They say he tried to shoot one of them, but the firearm malfunctioned.
As he tried to clear it, the gun went off and one victim was grazed by the bullet.
Thomas then walked to Kepler Neighborhood School, where students had just finished PE class.
Authorities say he threatened a teacher who also happens to be a former police officer.
That teacher spoke with Thomas, who then left the campus.
Police arrested him nearby moments later.