Gunmen dressed in police uniforms killed a 10-year-old boy and a guard when they fired at an opposition politician in the southern Pakistani port city of Karachi, police said.

The attack on Friday took place in the central Buffer Zone district when Khawaja Izharul Hassan from the Muttahida Qaumi Movement (MQM) was hugging people after an Eid al-Adha prayer gathering.

Four others were wounded in the attack, as Hassan remained unharmed, senior police official Zulfiqar Larak told the AFP news agency.

"Unknown gunmen opened fire on Khawaja Izharul Hassan when he was meeting people after Eid prayers. His guard and a boy, about 10 years old, were killed while four others were including another guard were wounded in the firing," Larak said.

Another senior police official, Pir Mohammad Shah, said one of the gunmen was also killed when Hassan's second guard, who was also wounded in the attack, fired back.

@IzharulHassan escaped assassination attempt, still at ground. 3 of his police guards took bullets, 1 martyred, few namazis as well pic.twitter.com/XrzCGTI6Su — Faisal Subzwari (@faisalsubzwari) September 2, 2017

Faisal Subzwari, an MQM politician, tweeted a photo of the scene showing Hassan on the right.

Police official Shah said the attackers came in police uniforms so they were able to pass through various check points unhindered.

MQM leader Farooq Sattar condemned the shooting and criticised federal and provincial governments for not providing adequate security to opposition politicians despite threats from banned outfits.

"I strongly condemn this attack on Khawaja Izharul Hassan," Farooq said. "My party colleagues and myself are facing threats from banned sectarian milita outfits and other organisations but federal and provincial governments have failed to provide us adequate security."

Karachi, one of the world's most violent cities, has more than 14 million inhabitants and is a major business and industrial hub.

It is Pakistan's largest city and rife with political, sectarian and ethnic tensions.

A strategic operation by security forces in recent years has brought a lull in violence, but scattered attacks still take place.