Gunmen opened fire on a political rally in the Pakistani city of Karachi on Tuesday, killing at least nine people and sparking rioting, police said.

The violence was a reminder of the port city's volatility. It is home to several political parties with armed wings that extort its citizens and feud among themselves, leading to frequent outbreaks of violence.

City police chief Akhtar Gorchani said nine people were killed and more then 30 wounded in shootouts. Another police officer, Mohammed Amir, said the attackers fired on a rally held by Awami Tehrik, a small nationalist group, and it was attended by members of several other parties in the city.

Several cars and shops were burned following the incident.

It was unclear who the attackers were, Amir said. He said authorities were trying to restore order.

Karachi is home to 18 million people and is the commercial hub of Pakistan. But it is riven with ethnic, political and sectarian tensions, and is also believed to be a hiding place for Taliban and al-Qaida militants.

The latest violence there started hours after the Pakistani Navy said it had court-martialed three officers for "negligence" in connection with a dramatic Taliban attack on a naval base in the southern port city of Karachi last year.

The brazen, 18-hour assault on Naval Station Mehran last May destroyed two U.S.-supplied surveillance aircraft and killed 10 people on the base.

The ability of the militants to penetrate the high-security base led to speculation they may have had inside information or assistance.

The three naval officers were punished for "negligence in their duty performance," but there was no evidence they were linked to the militants or helped them attack the base, said Navy spokesman Commodore Irfanul Haq. He declined to identify the names or ranks of the officers, or provide details about their punishment.

Military personnel who are court-martialed in Pakistan can be stripped of their rank and kicked out of the force, depending on the severity of the verdict handed down by the military court. They could also be demoted in rank.

The base attack was an embarrassment for the Pakistani military, especially since it came about three weeks after U.S. commandos killed al-Qaida chief Osama bin Laden in a covert raid in the northwest Pakistani town of Abbottabad. The operation outraged Pakistani officials because they were not told about it beforehand and left the Pakistani military red-faced because they were unable to stop it.

The Pakistani Taliban claimed responsibility for the base attack and said it was in retaliation for the killing of bin Laden.