Gunman killed five co-workers and injured five police officers before he was shot dead in the US state of Illinois.

An attacker opened fire at a suburban Chicago factory after being fired from his job there on Friday, killing five co-workers and wounding five police officers before he was killed by police, authorities said.

The assailant, Gary Martin, 45, “was being terminated” before he started shooting his co-workers in the city of Aurora, 65km west of Chicago, according to the police chief, Kristen Ziman.

Ziman told reporters that in addition to the five employees killed, a sixth worker was taken to a hospital with injuries that were not life-threatening. A sixth police officer suffered a knee injury while officers were searching the building.

Ziman said officers arrived within four minutes of receiving reports of the shooting and were fired upon as soon as they entered the manufacturing warehouse.

Police had yet to determine whether the shooting was an impulsive act or premeditated and investigators had not immediately ascertained why has been fired from his job at the factory, she added.

She said police executed a search warrant at his residence to further their investigation of what she called a “workplace shooting”.

“May God bless the brave law enforcement officers who continue to run toward danger,” said JB Pritzker, governor of the state of Illinois, where Aurora is located.

John Probst, an employee at the Henry Pratt Co, where the shooting took place, told ABC7 News that he ran out of the back door as the shooting unfolded on Friday afternoon.

Probst said he recognised the gunman and that he works for the company.

“What I saw was the guy running down the aisle with a pistol with a laser on it,” Probst said.

Probst said he was not hurt but that another colleague was “bleeding pretty bad”.

Police Chief Ziman said authorities did not know if he had legally purchased the gun he used.

Public records showed Martin had a criminal past, a 1995 conviction for aggravated assault in Marshall County in the state of Mississippi. Convicted felons are barred from buying firearms.

Martin’s mother told the Chicago Sun-Times newspaper that her son had been “way too stressed out” recently.

The White House said President Donald Trump was briefed on the shooting and monitoring the situation as he prepared to depart for a weekend trip to his home in Palm Beach, Florida.

Trump tweeted his thanks to law enforcement officers in Aurora and offered his condolences to the victims and their families. “America is with you,” he said.