Image copyright CBS

A police officer saved many lives at an Illinois high school when he shot a former student who opened fire on campus, say authorities.

Officials say Dixon police officer Mark Dallas exchanged gunfire with the unidentified 19-year-old suspect, who was previously expelled.

Neither the officer nor any students were hurt in Wednesday morning's confrontation at Dixon High School.

The suspect was taken to hospital with non-life threatening injuries.

Image copyright CBS

The incident took place at 08:00 local time at the school - which is about 100 miles (160km) west of Chicago - as students were rehearsing for their forthcoming graduation ceremony.

After firing several shots in a school hallway, the suspect - named in local media as Matthew Milby - ran outside the building where he was confronted by the officer.

A gunfight broke out, and the former student was injured and taken into custody.

Image copyright Dixon Police/Twitter Image caption The suspect, 19-year-old Matthew Milby

Authorities have not specified the suspect's motive or intentions.

Dixon Police Chief Steven Howell said: "I could not be more proud of the police officer. Because of his heroic actions, many lives were saved.

"With shots ringing out in the hallways of the school, he charged toward the suspect and confronted him head on."

As the school was placed on lockdown, students barricaded classroom doors with bookcases and desks, the chief added.

Brandon Stehl, a student who was in the gym, told Sauk Valley Media he initially thought the gunfire was a prank.

"This is something I never thought would happen. I wish it wasn't real," he said.

Image copyright Dixon Police/Twitter Image caption Officer Mark Dallas, the heroic officer who confronted the suspect

Another student, Brianna Johnson, told the newspaper of the suspect: "He seemed like a really nice kid, but then everything changed and he was angry and high all the time."

Dixon Mayor Liandro Arellano Jr said: "A lot of things went right today and many things could have gone wrong."

Illinois Governor Bruce Rauner took to Facebook to praise the officer.

In March, the school celebrated Officer Dallas' birthday with a tweet.

Ronald Reagan, the 40th US president, graduated from Dixon High School in 1928.

Meanwhile, a school resource officer who failed to prevent a mass shooting at a high school in Parkland, Florida, in February is picking up a generous pension.

Scot Peterson, who was assigned to protect Marjory Stoneman Douglas High School, is receiving $8,700 (£6,450) a month in retirement payments, state officials disclosed on Wednesday.

Seventeen people died as he lingered outside the building with his gun drawn while the shooting - also allegedly by an expelled former student - unfolded.

Florida Department of Management Services spokeswoman Nina Ashley said that because Mr Peterson has not been charged with a crime, they are unable to alter his pension payments.

Media playback is unsupported on your device Media caption School surveillance camera shows deputy waiting outside

Andrew Pollack, the father of a slain student who is suing the officer, expressed his anger about the pension on Wednesday.

"He hid while my daughter and 16 others were slaughtered! How in the hell is he getting this?" he tweeted.

"That money should go to actually securing our schools."

Fred Guttenburg, whose daughter, Jaime, was killed at the school, also took to Twitter, writing: "This infuriates me in ways people cannot comprehend.

"My daughter would still be alive if this person did his job."

More on school shootings

Is it time for US teachers to carry guns?

'Arm me with anything but a gun'