An officer confronted an armed 19-year-old man who opened fire at an Illinois high school Wednesday morning, an encounter that ended with the suspect injured and in custody. The officer was praised in the aftermath, as authorities said his actions saved lives.

The incident in Dixon, Ill., unfolded when police received a report of an “armed male subject” in Dixon High School about 8 a.m. Wednesday, Dixon Police Chief Steven Howell said at a press briefing.

A preliminary investigation found that the suspect fired several shots near a gymnasium, Howell said. At that point, he was confronted by a school resource officer.

Danny Langloss, Dixon’s city manager, identified the school resource officer as Mark Dallas, whom he called a “great guy” and a “true servant,” someone with a passion for children in the community.

“And today, with no regard for his own safety, he went right to the gunshots and confronted the suspect,” Langloss said.

Dallas has been with the Dixon Police Department for more than a decade and has spent the past few years as school resource officer, according to Langloss.

The suspect, a former Dixon High student, left the school when the officer confronted him, and ran, Howell said. The officer chased after him.

“While pursuing the suspect, the suspect shot several rounds toward the officer,” Howell said. “At which time, the officer returned fire and struck the suspect.”

The suspect, whose name was not immediately released at the briefing, was taken into custody, Howell said. His injury was not considered life-threatening.

Seniors had gathered for a graduation rehearsal in the gym when the incident happened,  Langloss said. The group included his own daughter.

“It’s incredibly scary,” Langloss said. “If he would have made it into the gymnasium, her and her friends would have been the first ones he would have encountered. I’m just grateful for the heroic actions of Officer Mark Dallas. He saved a lot of lives today.”

Dixon is a city in Northern Illinois, about 100 miles from Chicago, and was the boyhood home of Ronald Reagan. The news conference was streamed on Facebook by WQAD-TV.

No students, staff or other members of the community were injured during the episode, Howell said. Authorities did not believe there was a further threat, and they think the suspect acted alone, though the investigation was ongoing.

Students and staff at the high school responded “extremely well” to the situation, Howell said, adding that the district has received police department training on how to respond to shooters.

“While removing students from the various classrooms, responding officers found the staff [and] students had barricaded the doors to the classrooms with desks, bookcases and other objects,” Howell said.

Howell praised the school resource officer, saying he “could not be more proud” of him.

“With shots ringing out through the hallways of the school, he charged toward the suspect and confronted him head-on,” he said. “Because of his heroic actions, countless lives were saved. We are forever indebted to him for his service and his bravery.”

Lee County Sheriff John Simonton also lauded the officer’s actions, saying he saved an “enormous amount of lives in the school today.”

“In addition to that, we need to take a look at what happened at the school,” he said. “Because we do teach the students and faculty how to respond to these types of events. And from what I’ve been told . . . they did exactly what we asked them to do during the training.”

The incident on Wednesday was “horrific,” Simonton said. Then he added: “However, it could have been a lot worse.”