DIXON, Ill. — Charges were filed against a student who was wounded by a police officer after firing shots in a northern Illinois high school hallway while staff and seniors were meeting for a graduation rehearsal, Illinois State Police announced late Wednesday.

Matthew A. Milby, 19, of Dixon is charged with aggravated discharge of a firearm, aggravated discharge at a school employee and aggravated discharge at a school building. Milby, who was wounded in an exchange of gunfire with a school resource officer, remains hospitalized with what authorities describe as non-life-threatening injuries and is under surveillance. A Lee County judge set bond at $2 million.

Officer Mark Dallas, who has worked at Dixon High School for five years, was hailed as a hero for shooting and arresting Milby.

"He saved an enormous amount of lives," Lee County Sheriff John Simonton said. His comments were echoed by Illinois Gov. Bruce Rauner, who in a statement credited "Dallas for his bravery and quick action to immediately diffuse a dangerous situation."

Police Chief Steven Howell Jr. said several shots were fired near the auditorium, and Dallas rushed to the area to confront the gunman.

Howell said Dallas chased the suspect after he fled from the school. The suspect fired several shots at the officer, who returned fire, wounding the suspect and taking him into custody.

Police said they believe the gunman acted alone and that there was no further threat to anyone in the area. Howell declined to discuss why Milby brought a gun to the school.

"I could not be more proud of the police officer and the way he responded to the situation. With shots ringing out through the hallways of the school, he charged towards the suspect and confronted him, head on," Howell said of the 15-year veteran of the Dixon Police Department. "Because of his heroic actions, countless lives were saved. We are forever indebted to him for his service and his bravery."

Authorities originally said Milby wasn't a student at the school. However, Superintendent Margo Empen told Sauk Valley Media the suspect was not expelled, did not drop out and was eligible to graduate with his class.

Empen said she could not provide further details because of school privacy laws.

When police searched the school after the shooting, they found that the faculty and students had barricaded themselves inside by blocking the classroom doorways with desks, chairs and other furniture — just as they had been trained to do.

"A lot of things went right today and many things could have gone wrong," Dixon Mayor Liandro Arellano Jr. told reporters at a news conference outside the school.

Officials said all schools in the city about 80 miles (130 kilometers) west of Chicago were placed on lockdown in the immediate aftermath of the shooting. The other schools reopened after officials determined the gunman acted alone.