Rashaad Byrd was arrested after a seven-year-old found Byrd's gun and brought it to school in Elgin.
Another student saw the gun in the boy's backpack and told a teacher.
Byrd was apparently staying with the child's family.
Byrd also faces charges of not having a firearm owner's identification card, and for misdemeanor child endangerment.