A disgruntled employee, who fatally shot five people and wounded five police officers at an Illinois warehouse on Friday, severely beat a woman years ago in a domestic violence incident that turned him into a felon - and should have kept him from buying a gun.

Gary Martin, 45, who was shot and killed during the attack, applied for a concealed carry permit five years ago, alerting Illinois authorities to his criminal record, which made it illegal for him to own a gun. But Martin carried a weapon into a meeting at which he was to be fired from the Henry Pratt Co, gunning down three people in that room - including a human resources manager and a 21-year-old intern who was on his first day of work for the company - and two others who were nearby.

Authorities did not say why Martin was being fired.

"He doesn't take loss or rejection at all," said Martin's former girlfriend Chyreese Jones, 52, who brought charges against him that led to his felony conviction after he stabbed her several times with a kitchen knife and beat her with a baseball bat in Mississippi in March 1994. "He is going to be in charge. He is going to have something, a knife or a gun, and he is going to win."

Martin pleaded guilty to aggravated assault and was sentenced to five years in prison, though records show he served less than three years. He later moved to Aurora, Illinois, where he spent 15 years working at the warehouse.

Mass shootings in America Show all 8 1 /8 Mass shootings in America Mass shootings in America Camden shootings – 1949 Howard Unruh killed 13 people, including three children, during a 12-minute walk through his neighborhood on September 6, 1949, in Camden, New Jersey, when he was 28 years old. The incident became known as the "Walk of Death". Unruh was found to be criminally insane and died in 2009 after a lengthy illness at the age of 88, following 60 years of confinement. Alamy Mass shootings in America University of Texas tower shooting – 1966 Charles Whitman killed 17 people and injured 31 others in Austin, Texas. After stabbing his mother and wife the night before, he headed to the University of Texas, where he opened fire on people in the campus and streets from the observation desk. He was shot dead after a policeman and civilian reached the scene. Austin History Center, Austin Public Library Mass shootings in America Easter Sunday Massacre – 1975 James Ruppert killd 11 family members in his mother's house, which included his mother, brother and his wife, as well as their eight children. He used a magnum, two handguns and a rifle. Mass shootings in America Wilkes-Barre shootings – 1982 Former prison guard, George Banks, shot dead 13 people in Pennsylvania, including five of his own children. AP Photo/Times Leader Mass shootings in America Wah Mee massacre – 1983 Three men, Kwan Fai Mak, Wai-Chiu Ng, and Benjamin Ng, killed 13 people who were in Seattle's Wah Mee gambling club. YouTube/KIRO 7 News Mass shootings in America San Ysidro McDonald's massacre – 1984 James Huberty killed 21 people and injured 19 others after he walked in a McDonald's in San Diego. He was shot dead by a sniper after 78 minutes of him entering the restaurant. Alamy Mass shootings in America Palm Sunday massacre – 1984 Ten people were shot dead from handguns at close range in a New York home. A baby girl was the only survivor after convicted dealer, Christopher Thomas, shot three women, one teenage girl and six children in their Brooklyn home. Thomas was convicted of manslaughter and cleared of murder. He was released from prison after 32 years. Mass shootings in America Edmond post office shooting – 1986 Patrick Sherrill, a postal worker at the Edmond post office in Oklahoma, killed 14 co-workers and injured 6 others, before he shot himself. Oklahoma Highway Patrol Collection

Authorities said Martin obtained an Illinois Firearm Owner's Identification Card in January 2014 despite his felony record, which Aurora Police Chief Kristen Ziman said would not necessarily have shown up on a criminal-background check. Some states and local jurisdictions provide incomplete records to the federal database, and sometimes human error leads to missed information. The card is required to buy guns and ammunition in the state.

Martin later bought a Smith & Wesson .40-caliber handgun and applied for the concealed carry permit, which required fingerprinting. During that process, officials discovered Martin's felony conviction. His application for the permit was rejected, and his FOID card was revoked.

Those whose FOIDs have been revoked receive a notice from the Illinois State Police, telling them to surrender the card and list all the firearms in possession. But the law does not require authorities to confiscate the firearms. Instead, the letter asks people to specify that they either no longer have possession of the firearms or have given them to another person.

Ms Ziman identified Friday's victims as Clayton Parks, a human resources manager at Henry Pratt; Trevor Wehner, a human resources intern and a student at Northern Illinois University; Russell Beyer, a mould operator; Vicente Juarez, a stock room attendant and forklift operator; and Josh Pinkard, a plant manager.

In a statement, Northern Illinois University President Lisa Freeman, confirmed Wehner, who was expected to graduate in May with a degree in human resources management, was on the first day of an internship, working with Parks.

A family friend of Wehner, Cynthia Rose Cascarano, described him in a Facebook post as a big brother to many boys in the community and a great role model.

"Each and every one of us have had a 'First Day' on the job," Ms Cascarano wrote. "His should have never ended this way."

Aside from his felony, Martin had been arrested six times by Aurora police on traffic and domestic violence issues. He was arrested most recently in 2017, by police in nearby Oswego, Illinois, for disorderly conduct and damage to property, authorities said.

Police do not know whether Martin knew of his termination and planned the shootout beforehand. But Dennis Rokop, a retired nuclear project manager, said that as a union employee, Martin was probably aware that he was facing a termination meeting.

"You don't just fire a union guy," Mr Rokop said. "You have to build a case against him. It's a big drawn-out process."

About 200 people work at Henry Pratt, which is owned by Atlanta-based Mueller Water Products.

"Our hearts are with the victims and their loved ones, the first responders, the Aurora community and the entire Mueller family during this extremely difficult time," the company said in statement.

Neil Van Milligan, a former supervisor who no longer works at Henry Pratt, said Martin worked for him sporadically over four years, usually packaging up valves.

"He had kind of an attitude," said Mr Van Milligan, recalling how Martin repeatedly broke the rule against using mobile phones on the plant floor.

"He'd just kind of look at you like you were stupid for telling him not to do something," Mr Van Milligan said. "Knowing him and the way his attitude was, it doesn't surprise me that he got reprimanded."

A sign on the front door of the Henry Pratt Company office shows that guns are not allowed in the building (Getty Images)

On Saturday, neighbours in the cluster of three-story apartment buildings where Martin lived, in a blue-collar neighbourhood on the outskirts of Aurora, said some had heard Martin was fighting to keep his job. Steve Spizewski, who lived three doors down from Martin, saw a kinder side to him. They would hang out together, Mr Spizewski said, playing video games or watching movies.

When Mr Spizewski's mother died recently, Martin was the person who consoled him. Mr Spizewski had never thought of Martin as a man who might use a weapon.

"I knew he had an air rifle," he said. "I didn't know he had a gun gun."

But Mr Spizewski also said Martin had a troubled recent relationship with a girlfriend who had damaged his car, and he had mounted a camera on a post overlooking his assigned parking spot to protect his prized possession.

When Mr Spizewski saw Martin earlier this week, however, he had no idea that anything was wrong.

"He had a cigar in his mouth, a fedora on his head," Mr Spizewski said.

Martin often bought cigars from a Circle K not far from where he lived, where he struck up a friendship with Ricardo Moreno, an assistant manager.

Martin came in almost every morning as he left for work on the early shift and would purchase two to three cigars - the "Black and Mild Jazz" brand.

The two men bonded over 30-minute conversations about topics ranging from women to the news. When mass shootings, notably Las Vegas and Parkland, were in the headlines, Martin did not have much to say.

"He tried to stay away from bad vibes," Mr Moreno said.

He also never talked about partying or going to bars, Mr Moreno said, noting he mostly stayed at home.

Mr Moreno said he last talked with Martin two weeks ago, when he said he was dating a new woman.

"Life's good, everything's going good," Mr Moreno said Martin told him.

Ms Jones attributed Martin's anger to problems that dated to his childhood in Aurora. He never had a father figure in his life, she said, and he had such a strained relationship with his mother that he moved to Mississippi where he lived with his grandmother and other relatives.

"He is a nice guy - was a nice guy," she said, "But he was dealing with demons of some sort."

Martin's mother declined to comment.

Aurora shares a name with a Denver suburb that endured a mass shooting almost seven years ago. A gunman, James Holmes, opened fire inside a movie theatre in 2012, killing 12 people and injuring 70 others. The similarity was not lost on Nick Metz, the police chief of Aurora, Colorado.

"Months from now as people talk about the mass shooting in Aurora, someone will ask, 'Which Aurora mass shooting are we talking about?'" he tweeted.

Court records of the altercation that led to Martin's felony conviction show after he stabbed Ms Jones, neighbours called the police, who found her bleeding badly from her head, neck and back. They found Martin that night at a relative's house after he had tried to slash one of his wrists and cut his neck, according to court records.

"He told me that if we was going to end it, we was going to go out with a bang," Ms Jones said, according to the records. "We are all going to die."