A TEEN gunman opened fire with a high-powered rife outside a school formal in the US state of Wisconsin, wounding two students before a police officer in the parking lot fatally shot him.

The attack happened late on Saturday outside the Antigo High School formal, according to police chief Eric Roller.

Mr Roller said the gunman — later identified as Jakob E. Wagner — shot the two students as they exited the building.

Friends say Wagner was raised by his mother and grandparents, and was reportedly interested in guns.

Dakota Mills, who has known Wagner since the sixth grade, said he wanted to become a hunter, and completed a hunter safety course. But it was not clear if he owned his own gun.

Interim district administrator Donald Childs said Wagner did not graduate with his class last year and was still working on his diploma.

“For him to do that, something just isn’t right. He was a good kid,” Mills said.

Wagner loved video games and music, particularly violin and cello, and had been in the school marching band, Mills added.

Fellow student confirms this is Jakob Wagner, the 18-year-old who shot 2 at an Antigo prom. https://t.co/DGnrezuS70 pic.twitter.com/eoMPxZcs24 — Journal Sentinel (@journalsentinel) April 24, 2016

Dylan Dewey, who graduated from Antigo High last year, said Wagner had been dating a girl at the school who broke up with him last month. He described Wagner as an “all-around good guy” who enjoyed hanging out with friends.

The Unified School District of Antigo said Wagner had approached the school with the rifle and a large ammunition clip.

In a statement, the district said “quick actions” taken by authorites to secure the building “prevented what might have otherwise been a disaster of unimaginable proportions, and we are extremely grateful for their well-rehearsed response”.

UPDATE: Lone suspected gunman at Wisc. high school prom dies after being shot by police https://t.co/dgb4xhghpr pic.twitter.com/Joh8kEy0aZ — CBS News (@CBSNews) April 24, 2016

He didn’t say if investigators believe they were specifically targeted or what the motive was.

“Officers were in the parking lot patrolling the activities and heard the shots and an officer immediately fired upon the shooter, stopping the threat,” he said.

Wagner and the two victims — a male and female whose identities haven’t been released — were taken to hospitals.

Langlade County Coroner Larry Shadick said Wagner died in the intensive care unit of a Wausau hospital. He said further details would have to come from police.

The female victim was treated and released and the male victim was undergoing surgery for injuries that weren’t life-threatening, police said.

Interim district administrator Donald B. Childs told The Associated Press the wounded boy, who was shot in the leg, attended the high school but that his date, who was grazed in the shooting, was from out of state.

Gov. Scott Walker praised the police response to the shooting, saying in a statement the actions of the Antigo Police Department “undoubtedly saved lives.”

Childs said the school’s 750 students will have counsellors available when classes resume Monday.

The Wisconsin Department of Justice’s Division of Criminal Investigation has been asked to lead an outside review of the officer-involved shooting, agency spokesman Johnny Koremenos said.