Heavily armed gunmen opened fire on a vehicle carrying Mexico City's security chief on Friday, wounding him and killing two of his bodyguards as well as a woman passerby, the city's mayor said.

Mayor Claudia Sheinbaum told a press conference that Omar Garcia Harfuch had been taken to hospital but was out of danger.

Garcia Harfuch, 38, said from his hospital bed that he was hit by three bullets in the attack, which he said was carried out by the powerful Jalisco New Generation drug cartel.

"This morning we were cowardly attacked by the CJNG (Jalisco New Generation Cartel). Two colleagues and friends of mine lost their lives." Garcia Harfuch tweeted.

"I have three bullet wounds and several pieces of shrapnel."

Despite growing drug cartel violence in Mexico over the last decade, the capital remains relatively calm compared to other areas of the country.

A woman who was driving past the scene of Friday's attack was also killed, the mayor told a press conference.

"Two elements of the secretary's security team lost their lives," Sheinbaum told reporters.

"Unfortunately, a woman who was travelling in the area by car lost her life."

Mexico City's Public Safety chief said from his hospital bed that he was hit by three bullets in the attack he said was carried out by the powerful Jalisco New Generation drug cartel
Mexico City's Public Safety chief said from his hospital bed that he was hit by three bullets in the attack he said was carried out by the powerful Jalisco New Generation drug cartel AFP / Pedro PARDO

Twelve people had been arrested after the attack, the mayor said.

She said the gunmen used a truck to block Garcia Harfuch's car before opening fire. The attack happened around 6:30 am (1130 GMT).

Security forces cordoned off the residential area of Lomas de Chapultepec in the city.

Images on social media showed a black car riddled with bullets, with bullet casings littering the street.

Six organized crime groups operate in Mexico City and the vast metropolitan area, National Defense Secretary Luis Sandoval said Thursday.

Mexico's Minister for Security and Citizen Protection, Alfonso Durazo, condemned what he called a "cowardly attack on a public servant dedicated to the security and peace of the inhabitants of the country's capital".

Garcia Harfuch has been Mexico City security chief since October last year.

jla/gm/db/dw