A former student was brought down by police after opening fire on his old Illinois high school on Wednesday morning.

The 19-year-old suspect, who has not been named, was shot as he ran away from school resource officer Mark Dallas after opening fire near the west gym at Dixon High School at 8.06am.

He is in hospital receiving treatment for non-life-threatening injuries. No one else was hurt.

When he opened fire, seniors were gathering near the gym to take part in a rehearsal for graduation.

Scroll down for video

Students from Dixon High School in Illinois were evacuated and bussed to a baseball field on Wednesday morning after a teenage gunman was brought down by a school resource officer

Students are seen getting on to buses after the incident at 8am. According to witnesses, the gunman was brought down in the school gym where seniors getting ready for a graduation rehearsal

The children were reunited with their parents who gathered at the field as reports of the shooting emerged

At 8.06am, the gunman fired 'several' rounds on the campus.

It is not clear where Dallas was stationed at the time but he was able to confront the shooter quickly, Dixon Police Chief Steve Howell said.

School resource officer Mark Dallas shot the teen. He has been hailed a hero

After confronted, the shooter started running westbound off the school's campus.

Dallas gave chase.

As he ran, the shooter turned and fired several shots at the cop but missed.

That was when Dallas drew his gun and shot him.

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

'Because of his heroic actions, countless lives were saved. We are forever indebted to him for his courage and his bravery,' Howell said.

After hearing the first shots, teachers and students barricaded themselves in their classrooms with books and desks.

They were later evacuated to a nearby baseball field where they were reunited with their terrified parents.

City Administrator Danny Langloss said students and staff were 'lucky' Dallas was there.

'We're lucky the officer was there. His brave actions saved a lot of lives,' he said.

Illinois governor Bruce Rauner echoed his praise.

A lot of things went right today when a great many of them could have gone wrong Mayor Liandro Arellano Jr.

'Today, we should all be very thankful to school resource officer Mark Dallas for his bravery and quick action to immediately diffuse a dangerous situation at Dixon High School,' he said.

Mayor Liandro Arellano Jr said: 'A lot of things went right today when a great many of them could have gone wrong.

'Things could have gone much worse. We are deeply indebted to our officer and the actions he took today.'

Once the shooter had been taken away by ambulance, students were allowed out of their classrooms to reunite with their parents on a campus baseball field.

Dixon Police Department gave the first details of the incident on Facebook.

The scene at Dixon High School in Illinois after a former student opened fire at 8am before being brought down by a school resource officer. No one other than the shooter was injured. He is in hospital being treated for non-life-threatening injuries

Illinois Governor Bruce Rauner was among those to praise Dallas for intervening

'A Dixon Police Officer confronted an armed male subject at the Dixon High School at approximately 8:00 am on May 16, 2018.

'Preliminary investigation shows the suspect shot at the police officer, the officer returned fire, and the suspect was injured.

'His injuries are believed to be non-life-threatening.

'The suspect is in custody and is receiving medical treatment. No students or staff were injured in the incident.

'The Dixon High School and all Dixon Public Schools are on lock down.

'Dixon Police believe the suspect acted alone and that there is no further threat to the safety of students or staff,' it read.

There was a large police presence at the scene after the 8am shooting. The school was put in lockdown but there is no outstanding threat to the community