An off-duty CDCR Correctional Sergeant shot a gunman, who was randomly shooting motorists, is being hailed by the Fresno Police Department as a “hero.”

The Sergeant, who was not identified, shot gang member Joshua Lewis, 21, of Fresno, four times as Lewis embarked on a shooting and carjacking attack, the Fresno Bee and police said. The gunman killed two people before the CDCR Sergeant intervened.

The wounded gunman fled in a stolen SUV, which he crashed a short time later. Lewis died of his wounds shortly later, police said.

Fresno Police Chief Jerry Dyer hailed the CDCR sergeant as a “hero.” There is “no doubt” that more people would have been killed if not for the CDCR Sergeant, Chief Dyer said.

Media reports and police gave this account:

The off-duty CDCR Sergeant, a former Marine, left his vehicle and headed toward Lewis after Lewis’ carjacking attempt failed and he began shooting motorists stranded in their cars.

The Sergeant’s wife tried to stop him.  “He tells his wife, ‘Babe, I’ve got to go — duty,’ ” said Fresno Police Detective John Viveros.

A witness told the Fresno Bee that he watched the CDCR Sergeant and another armed civilian approach Lewis.

“It was scary,” the witness said. “Thank God for those two guys … He would have killed more people… If it wasn’t for the (CDCR Sergeant), he might have gone after more cars.”

Police don’t know why Lewis started shooting indiscriminately.

According to court records, the Fresno Bee reported, Lewis was arrested two years ago for street terrorism and carrying a loaded firearm in public. In June 2012, he was given a three-year suspended sentence and got three years probation in exchange for his no-contest plea.