A 10-year-old boy was charged after bringing a loaded handgun into a Baldwin elementary school Monday, and it was confiscated after a sharp-eyed lunch monitor spotted him and another student repeatedly peering into the boy’s lunch bag, county officials and police said.

In the bag was a .40-caliber gun that had one round in the chamber and several in the magazine, Nassau Police Commissioner Patrick Ryder said at a news conference outside Meadow Elementary School, where he was joined by County Executive Laura Curran.

The boy was brought to the First Precinct, where he was processed with his father there, police said in a news release Tuesday morning. The boy was charged with criminal possession of a weapon on school grounds and is due back in Family Court on April 5.

Detectives are investigating the source of the gun and how the boy got access to it, police said.

Police said the student, a fourth-grader, arrived at the elementary school about 8:30 a.m. on a school bus, bringing the weapon in a lunch bag of blue fabric.

In the lunchroom at 11:15 a.m., the boy showed another student what the bag contained, and their fascination attracted the suspicions of the lunch monitor, police said.

“The lunch monitor, while looking over, noticed the bag to be apparently heavy, went over, lifted up the bag, looked inside and saw what appeared to be a handgun,” Ryder said.

Sign up for The Classroom newsletter. Education on Long Island is changing. Find out how. By clicking Sign up, you agree to our privacy policy.

The monitor took the boy to the principal, who called the school resource officers, who are First Precinct officers assigned to the school, authorities said.

The boy told officials he received the gun Sunday during a party at his uncle’s house, county officials said. The gun was unregistered, county officials said.

Curran, Ryder and school district officials praised the lunch monitor and school officials for a “textbook” response that followed the training they received as part of the police and county school safety program, which fully launched in September.

“Once that gun was recovered, that threat was removed,” Ryder said.

Ryder called the lunch monitor’s response “outstanding,” saying she took exactly the correct actions. Curran, who has two children in the district, also lauded the staffer and the district.

“I’m just happy that protocol was followed and that nobody was hurt,” Curran said in an interview. “We are relieved that the school district acted appropriately and nobody was hurt. . . .This is a wonderful school staffer who was aware and clearly looking out for her kids and did exactly the right things.”

The district and police declined to identify the lunch monitor.

In a letter to parents, Baldwin Superindent Shari Camhi said the staff’s “extensive safety training” kept students secure and that the district and police are “taking the appropriate disciplinary actions.”

“I want to assure you that the safety of all of our students and staff has always been and will continue to be a top priority of the Baldwin School District,” her letter read. “I ask that you take this time to remind your children that, if they ‘see something, say something.’ “

The district of about 4,600 students has five elementary schools. Meadow Elementary had 564 students in kindergarten through fifth grade in the 2016-17 school year, the most recent state Education Department figures available.