Attackers set off several car bombs and then rode by in vehicles armed with AK-47s and rocket-propelled grenades, shooting into the panicked crowd, according to the Associated Press.
Some of the gunmen wore the uniform of the Iraqi security forces, an official said.
The Iraqi army summoned help from the American military and surrounded the town of Mahmoudiya as ambulances evacuated casualties. Charred vendor stalls and vehicles lined the market area along a four-lane street running through the town, the AP reported.
The American and Iraqi soldiers responding to the emergency came under small arms fire. At least two attackers were captured, according to officials.
Al-Qaida in Iraq claimed responsibility in a sign hung on a nearby mosque and said the attack was revenge against the Mahdi Army, the Shiite militia accused of raiding neighborhoods in Baghdad last week and killing dozens of Sunni Arabs, according to The Washington Post.
Mahmoudiya is located in the dangerous “triangle of death” south of Baghdad, where Sunnis and Shiites live in mostly segregated neighborhoods. It is the same town where U.S. soldiers allegedly raped and killed an Iraqi girl and then killed three members of her family.
In the capital, Shiite legislators linked to Muqtada al-Sadr, the Shiite cleric who controls the Mahdi Army, stormed out of a parliament session to protest the attack.
A top aide to al-Sadr, Riyadh al-Nouri, blamed radical Sunni Muslim insurgents, those still loyal to former president Saddam Hussein and occupation forces for failing to quell the violence, although he added that mainstream Sunni residents “are innocent of this cowardly act.”
The mayor of the town said gunmen snuck in Sunday night around midnight and hid in the outskirts of the city until morning, according to the Post.