A motorist who was shot dead by a hero passerby after he had 'ambushed' an Arizona state trooper has been identified as a known drug user and illegal immigrant from Mexico.

Leonard Penuelas-Escobar shot trooper Edward Andersson twice on an interstate west of Phoenix, before he was killed by a Good Samaritan passerby on Thursday.

Penuelas-Escobar, who was believed to be under the influence of drugs at the time, shouted in Spanish at the 27-year department veteran before shooting and beating him in an 'ambush-style attack'.

The 37-year-old drug user was in the country illegally and is believed to have once worked as a Mexican police officer, the Department of Public Safety Director Frank Milstead said on Monday.

Leonard Penuelas-Escobar shot Arizona state trooper Edward Andersson twice on an interstate west of Phoenix before he was killed by a hero passerby, on Thursday. The 37-year-old drug user was in the country illegally and is believed to have once worked as a Mexican police officer

Edward Andersson is a 27-year veteran of the Arizona Department of Public Safety force. He was investigating a scene of a car wreck when he was shot in an ambush by Penuelas-Escobar

The incident began when Trooper Andersson was responding to an emergency call that reported shots fired from a median of a remote stretch of Interstate 10, west of Phoenix.

On his way he came across a wreck, where Penuelas-Escobar's car had rolled over and thrown his girlfriend, 23-year-old Vanessa Monique Lopez-Ruiz, from the vehicle. She was later pronounced dead.

Andersson stopped to investigate and began to set up flares to slow down oncoming motorists. As he was doing so Penuelas-Escobar began to open fire on him with a 9mm pistol, ABC 15 reported.

The trooper was shot between the right shoulder and chest, twice, Milstead said in a news conference on Monday.

Andersson was shot and was fought to the ground by Pennelas-Escobar. Officials said the illegal immigrant was on top of the officer and 'getting the better of him,' slamming the trooper's head into the pavement

That's when the passerby spotted the altercation and asked Andersson if he needed help. The officer said yes, and when Penuelas-Escobar ignored the passerby and continued attacking the trooper, the Good Samaritan shot him dead

Then the man began to physically attack Andersson, and landed blows with his fists and beat the trooper's head on the ground in what Milstead called an 'ambush-style attack'.

That's when the hero passerby spotted the altercation and asked the officer if he needed help.

Andersson said yes, and the passerby retrieved a handgun from his vehicle and fired two shots at Penuelas-Escobar after he refused to stop attacking Andersson.

Penuelas-Escobar's believed car had rolled over and ejected his girlfriend, 23-year-old Vanessa Monique Lopez-Ruiz (pictured), from the vehicle. She was later pronounced dead

Andersson was investigating this car wreck when he was attacked

With Penuelas-Escobar incapacitated, the motorist tended to the wounded trooper but was later drawn back into the dispute when Penuelas-Escobar got up and resumed his assault on Andersson.

The motorist then fired a fatal shot at Penuelas-Escobar.

Milstead said without the hero passerby's assistance, Andersson would have 'much more serious neurological injuries from this beating'.

He added: 'He's incredibly fortunate to be here with us today.'

Andersson underwent surgery and has since been released from the hospital.

Department of Public Safety Director Frank Milstead said of the hero passerby: 'He knows he did the right thing. He is trying to reconcile that in his mind, which is difficult to take a life even when you know it's the right thing to do'

The motorist who shot Penuelas-Escobar hasn't spoken out publicly about the shooting.

Milstead said the motorist didn't serve in the military or work as a law enforcement officer, but he still had experience in using firearms. The DPS director described the motorist as a humble man with a strong religious faith.

'He knows he did the right thing,' Milstead said. 'He is trying to reconcile that in his mind, which is difficult to take a life even when you know it's the right thing to do.'

Arizona has a 'defense of third person' law that allows someone to use deadly force against another who is threatening or injuring a third person. It was not unusual that the passing driver was armed in this gun-friendly state with loose regulation.