A disgruntled former factory worker went on a shooting rampage at his old workplace in Illinois on Friday, shooting dead five people and wounding five cops before being killed, authorities and reports said.

The chaotic incident unfolded around 1:24 p.m. local time at the Henry Pratt Company, one of North America’s largest manufacturers of water valves, in the city of Aurora.

Gunman Gary Martin, 45 — who had been laid off from the plant two weeks ago — wielded a pistol with a laser scope as he opened fire inside the facility, prompting a massive police response to the 29,000-square-foot building within minutes, Aurora Police Chief Kristen Ziman said at a press conference.

By 1:28 p.m., officers with the Aurora Police Department arrived on the scene “and were fired upon immediately,” Ziman said, noting that two of the initial four officers who entered the building were shot.

“Additional officers began to arrive and were also fired upon,” Ziman said, adding that “a total of five officers were struck by gunfire.”

The officers who were shot and injured were in stable condition, a city official had told CNN.

Ziman said several teams of officers went inside the facility “to locate and engage the offender,” and when they found him, “they engaged in gunfire with him, ultimately killing him.

“At this time we are not sure of the motive of this act of violence,” Ziman said.

But Tameka Martin, who identified herself as the shooter’s sister, told WBEZ 91.5FM that her brother was let go from the company two weeks ago after working there for 20 years.

His mom told the Chicago Sun-Times that her son “was way too stressed out’’ since he lost his job.

“He shot officers, so if they did shoot him, and kill him, they was, I guess, defending themselves,” Tameka said.

Henry Pratt employee John Probst described the mayhem that unfolded in the plant.

“One of the guys was up in the office. He said this person was shooting, and, he come running down, and he was bleeding pretty bad, and the next thing you know, he was walking back and forth, I heard more shots, and we just left the building,” Probst told ABC7.

Probst said he and another co-worker escaped the building through a back door.

Aurora Mayor Richard Irvin called Friday “a sad day in the city of Aurora.”

“It’s a shame that mass shootings such as this have become commonplace in our country,” Irvin said, adding “We will come together and heal as one Aurora.”

Illinois Gov. J.B. Pritzker said: “There are no words for the kinds of evil that robs our neighbors of their hopes and their dreams and their futures.

“To the families of the victims here in Aurora there are no words I can offer to lessen the pain but know that our state grieves with you,” the governor said.

President Trump said in a tweet Friday: “Great job by law enforcement in Aurora, Illinois. Heartfelt condolences to all of the victims and their families. America is with you!”

Aurora is a city of 200,000 people and is roughly 40 miles west of Chicago.