"A seemingly routine call turned into a deadly encounter within a split second," Chandler Police Chief Sean Duggan said at a news conference.
"Our officers are alive and just for that we are eternally grateful," Duggan said. "Both were shot multiple times, and both are presently in stable condition. ... Both officers were wearing their ballistic vests this morning."
The officers fired back at the suspect, killing him.
Police identified the suspect as 24-year-old Mitchell Oakley. Police said he was a homeless man who had family in the Chandler area. Chandler is suburb of Phoenix.
The incident began early Saturday when a Walmart employee inside the store recognized Oakley as someone who had previously trespassed, and the employee called police.
When two officers approached the suspect, "the suspect turned and shot both officers multiple times," Duggan said.
The names of the officers are not being released until family and relatives are notified, Duggan said.
Chandler Police Detective Seth Tyler said one of the officers was shot in the face and required surgery. Chief Duggan tweeted that one officer was in intensive care Saturday night, while the other has been released.
"They acted heroically," said Duggan. "They acted on their training, on their experience, on their equipment and they relied on each other to survive this deadly encounter."
Court records show Oakley was arrested several times in Arizona for offenses including attempt to commit aggravated assault on an officer, resisting arrest, and destruction of public jail.
The Walmart store in Chandler is normally open 24 hours, but it remained closed Saturday evening.
A shopper, Cynthia Ayala, was at the scene Saturday morning and spoke to CNN affiliate KPHO/KTVK.
"Honestly, I thought it was pallets falling," Ayala said. "I never thought it would be gunshots. And then it was clear after a couple of them that it was gunshots. And I was really scared. I didn't know if the bullets were going to come back down and hit me. I was really scared as to where they would fall."