The trooper suffered a severe wound to his shoulder and upper chest but he is expected to recover at a hospital.
"My trooper would not be alive without his assistance," Department of Public Safety Director Ralph Milstead said of the good Samaritan who stopped.
The drama unfolded at an early morning rollover wreck on Interstate 10 in the desert west of Phoenix where a woman was ejected and killed. Authorities believe the man who shot the officer was driving the car that crashed.
Officials said they were trying to determine exactly what happened and that the investigation faced major hurdles with the trooper seriously injured and two of the others involved dead. No identities have been released.
A separate driver reported gunfire and a trooper was responding to that call when he spotted the wreck and stopped, Milstead and DPS Capt. Damon Cecil said.
The officer was putting out flares when the suspect opened fire and then physically attacked the wounded trooper, Milstead said. Both Milstead and Cecil said the trooper was ambushed.
The man was on top of the officer and "getting the better of him," slamming the trooper's head against the pavement, Milstead said. That's when the passing driver showed up and asked if the trooper needed help.
He said yes, and the passer-by went back to his vehicle, got his gun and told the suspect to stop the attack, Milstead said. When he didn't, the driver shot him.
Investigators were trying to determine how the rollover happened and whether the suspect was involved with the initial report of gunshots, officials said. Investigators plan to speak with the person who made that call.
Milstead said he feared the worst when he headed to the hospital to check on the wounded trooper.
"He's incredibly fortunate to be here with us today," the director said.
Westbound Interstate 10 was closed most of the morning, and traffic heading for California and western Arizona was detoured to other highways.