The man who opened fire and killed five co-workers including the plant manager, human resources manager and an intern working his first day at a suburban Chicago manufacturing warehouse, took a gun he wasn't supposed to have to a job he was about to lose.

Right after learning Friday that he was being fired from his job of 15 years at the Henry Pratt Co. in Aurora, Gary Martin pulled out a gun and began shooting, killing the three people in the room with him and two others just outside and wounding a sixth employee, police said Saturday.

Martin shot and wounded five of the first officers to get to the scene, including one who didn't even make it inside the sprawling warehouse in Aurora, Illinois, a city of 200,000 about 40 miles (65 kilometers) west of Chicago.

After that flurry of shots and with officers from throughout the region streaming in to help, he ran off and hid in the back of the building, where officers found him about an hour later and killed him during an exchange of gunfire, police said.

"He was probably waiting for us to get to him there," Aurora police Lt. Rick Robertson said. "It was just a very short gunfight and it was over, so he was basically in the back waiting for us and fired upon us and our officers fired."

Like in many of the country's mass shootings, Friday's attack was carried out by a man with a violent criminal history who was armed with a gun he wasn't supposed to have.

Martin, 45, had six arrests over the years in Aurora, for what police Chief Kristen Ziman described as "traffic and domestic battery-related issues" and for violating an order of protection. He also had a 1995 felony conviction for aggravated assault in Mississippi that should have prevented him from buying his gun, Ziman said.

He was able to buy the Smith and Wesson .40-caliber handgun on March 11, 2014, because he was issued a firearm owner's identification card two months earlier after passing an initial background check. It wasn't until he applied for a concealed carry permit five days after buying the gun and went through a more rigorous background check using digital fingerprinting that his Mississippi conviction was flagged and his firearm owner's ID car was revoked, Ziman said. Once his card was revoked, he could no longer legally have a gun.

"Absolutely, he was not supposed to be in possession of a firearm," she said.

But he was, and on Friday he took it and several magazines of ammunition to work.

Scott Hall, president and CEO of Mueller Water Products Inc., which owns Henry Pratt, said that Martin came to work for his normal shift Friday and was being fired when he started shooting.

"We can confirm that the individual was being terminated Friday for a culmination of a various workplace rules violations," he told a news conference Saturday. He gave no details of the violations by Martin at the plant that makes valves for industrial purposes.

A company background check of Martin when he joined Henry Pratt 15 years ago did not turn up a 1995 felony conviction for aggravated assault in Mississippi, Hall said.

The employee who survived being shot is recovering at a hospital, Ziman said Saturday. None of the officers who were shot received life-threatening wounds, she said.

Police identified the slain workers as human resources manager Clayton Parks of Elgin; plant manager Josh Pinkard of Oswego; mold operator Russell Beyer of Yorkville; stock room attendant and fork lift operator Vicente Juarez of Oswego; and human resources intern and Northern Illinois University student Trevor Wehner, who lived in DeKalb and grew up in Sheridan.

It was Wehner's first day on the job, his uncle Jay Wehner told The Associated Press. Trevor Wehner, 21, was on the dean's list at NIU's business college and was on track to graduate in May with a degree in human resource management.

"He always, always was happy. I have no bad words for him. He was a wonderful person. You can't say anything but nice things about him," Jay Wehner said of his nephew.

___

Associated Press writers Carrie Antlfinger and Amanda Seitz contributed to this report. Babwin and Rousseau reported from Chicago.