An armed motorist saved an Arizona state trooper’s life early Thursday by killing a man who had shot the officer and was slamming his head into the pavement.

Trooper Edward Andersson was in serious but stable condition following surgery after he was shot in the right shoulder and chest in what authorities say was an ambush in the desert west of Phoenix.

. . . . As Andersson put out flares, the suspect opened fire and then attacked the wounded trooper. The man was on top of the officer and “getting the better of him,” according to Department of Public Safety Director Frank Milstead.

At that point the good Samaritan showed up and asked if the trooper needed help. After Andersson said yes, the motorist went back to his vehicle, retrieved his gun and told the suspect to stop the attack. When he did not relent, the driver shot him.

“The trooper says, ‘Please help me,’ and asks the uninvolved third party for help,” Milstead told NBC News. “That person retreats back to his vehicle, removes his own weapon from the vehicle, confronts the suspect, giving him orders to stop assaulting the officer. The suspect refuses. The uninvolved third party fires, striking and killing the suspect.”