A permit-to-carry holder shot an alleged robber in the ankle Thursday evening in St. Paul when a purported iPhone sale turned into an armed robbery, police said.

The alleged robber, Kendrick J. Maddox, was treated at Regions Hospital and arrested, said Sgt. Mike Ernster, a police spokesman. Maddox, 18, of Minneapolis, was charged Friday in Ramsey County District Court with one count of first-degree aggravated robbery.

The robbery victim was not injured or arrested.

The incident occurred about 5:30 p.m. in a parking lot in the 1100 block of Rice Street.

According to police and the criminal complaint against Maddox: the robbery victim, a 39-year-old man, and Maddox met on Facebook Marketplace where Maddox agreed to sell the man an iPhone X for $500.

When they met in the parking lot, the buyer started counting out the money in $20 denominations. At that point, Maddox “placed a black firearm to his side and took the money,” Ernster said.

The robbery victim drew his own .357 revolver and fired up to three shots at the suspect, who fled on foot. Police do not believe Maddox fired at the robbery victim at any point.

“[The robbery victim] said he feared for his life and fired in self-defense,” the complaint said.

The robbery victim fled the scene, called police and later returned to the area to assist in the investigation.

Officers responding to calls of shots fired found Maddox. He allegedly told them he was walking down the street and was shot, and denied any involvement in a robbery, or, Facebook communications regarding an iPhone.

Using a Facebook username provided by the robbery victim, police traced Maddox to a Facebook account that allegedly included photos of Maddox and an iPhone. The robbery victim also identified Maddox in a photo lineup.

Ernster said there is no information linking Maddox to similar incidents, although police investigate a “steady stream” of robberies that occur during transactions initiated online. The majority of those cases also involve smartphones or electronics, he said.

Aung Thu Bo, a 19-year-old Hamline University student, was fatally shot in the head in August 2012 after responding to a Craigslist ad for an iPhone. Steven E. Lewis, the supposed seller, robbed Bo and his girlfriend and then shot Bo in St. Paul.

“We want people to go to the most public places they can think of for online transactions,” Ernster said. “If the deal is too good, it probably is an indicator of possible deception.”