Police still were questioning the suspect, Adam Hernandez, 27, Wednesday night and authorities were determining what he would be charged with.
The marshals evidently spotted the the man later identified as Hernandez in the Chandler Fashion Center mall parking lot with a vehicle believed tied to local armed robberies, including a robbery that just had occurred at a nearby hotel, Chandler, Ariz., police Sgt. Joe Favazzo told ABCNews.com.
"It's my understanding that with very little hesitation he displayed a firearm and fired at one of the officers," Favazzo said. "Officers returned a couple of shots at him."
Nobody was hit by gunfire, which occurred around noon, police said. Hernandez then ran into the mall and eluded his pursuers, prompting the lockdown.
"They were able to quickly contain the mall," Favazzo said. "We now know that the suspect was able to get out of the mall before we got full lockdown completed."
Armed police officers wearing helmets and bulletproof vests searched the mall and a nearby strip mall for the suspect. Some of the officers used dogs in the search.
Witness: 'Snipers on the Roof'
Amanda Marshall, the front desk manager of a Springhill Suites hotel near the mall, said that when the mall was evacuated, some of the shoppers came to wait in the hotel lobby for rides.
Marshall said she could see snipers on the roof of a smaller strip mall across from the Chandler Fashion Center.
"There are at least two snipers on the roof on top of the Men's Wearhouse," she said.
However, it turned out Hernandez managed to escape to the Baja Fresh restaurant north of the mall, where he evidently grew spooked by the multi-jurisdictional police response and fired his gun inside the restaurant, prompting a standoff with police, Favazzo said.
"We set up police negotiations with him," Favazzo said. "He negotiated with officers and ultimately surrendered."
About three hours after the initial gunfire, around 3 p.m. local time, a man was seen walking out of the restaurant with his shirt off and hands up. He immediately was surrounded by SWAT team members with guns at the ready, handcuffed and taken into custody.
According to a written police statement, "At least two victims/citizens were in the business while the suspect spoke to police negotiators."
Those two reportedly emerged as Hernandez surrendered.
After officers identified Hernandez as the man who shot at them, "the lockdown was lifted from Chandler Mall and the scene was determined secure," police said.
Half an hour after Hernandez surrendered, a reporter for ABC News Phoenix affiliate KNXV saw police handcuff a second person at a Sears store at the mall. That person's identity remained unknown, but KNXV reported the incident was unrelated to the shootout.
Police are trying to determine the circumstances of that incident, but Hernandez was the only person arrested for the mall shootout, Favazzo said.
Fugitive Daniel Munoz Perez Not Involved in Mall Incident
During the mall lockdown, there were incorrect reports that the marshals exchanged fire with Daniel Munoz Perez, 25, a fugitive who has been on the run since last month.
"U.S. Marshals task force members attempted to arrest Daniel Perez, who is wanted for aggravated assault for shooting at an Arizona Department of Public Safety officer last month," said Jeff Carter of the United States Marshals Service during the incident. "The store is being locked down and the mall evacuated."
Perez was arrested Dec. 10 for the shooting of the DPS officer, but mistakenly was released from the Pinal County Jail on Dec. 16.
However, Favazzo said afterward that apparently Perez never was involved in the mall incident.
"At no point did any of us have confirmation that it was Perez" involved in the shootout, Favazzo said. "Ever."
ABC News' Jason Ryan and ABC Affiliate KNXV contributed to this report.