Two students attending a northern Wisconsin high school prom were wounded when struck by bullets fired by a teenage gunman who was shot by police and later died, police said Sunday.

The shooting happened outside Antigo High School around 11 p.m. Saturday, near the end of the event, according to WSAW-TV, and the school district said the quick action of staff and police “prevented what might have otherwise been a disaster of unimaginable proportions.”

Police identified the gunman as 18-year-old Jakob Wagner, a former Antigo student. Police said he had acted alone.

A school administrator said he does not believe Wagner targeted the victims.

Instead, interim district administrator Donald Childs said he believes Wagner planned to enter the prom and start shooting randomly.

Childs said Wagner was continuing to work on his diploma after failing to graduate with his Antigo class last year.

The teen, armed with a high-powered rifle and a large ammunition clip, approached the school as two prom attendees were leaving, the Antigo School District said in a statement.

“He fired at both, wounding one in the leg and grazing the other,” the statement said.

“Because Antigo police were stationed to patrol the parking lot, they responded immediately, and an officer returned fire, severely wounding the shooter,” the statement said.

Police said they were informed at 1 a.m. Sunday that Wagner had died.

The victims were a girl and a boy, police said.

The female was treated for a gunshot wound at the hospital and released and the male underwent surgery for non-life threatening injuries, police said.

Wagner had not attended the prom, Fox News reported.

The prom was locked down for several hours until authorities could determine there was only one gunman, Fox News reported.

A friend of Wagner’s, Dylan Dewey, 18, told the Associated Press that Wagner continued to help out at the school in one of the art classes.

Dewey said Wagner had been dating a girl at the school but that she had broken up with him last month.

Dewey said Wagner was an “all-around good guy” and said he generally seemed happy.

Antigo, a community of about 8,000 people, is roughly 150 miles north of Milwaukee.

The Associated Press contributed to this report.