Gunmen opened fire indiscriminately in the open-air market, and there were reports of explosions at the scene.
Many women and children were among the casualties. Most of the victims were believed to be Shia Muslims.
The town, which has a mixed Shia and Sunni population, has been the scene of frequent bombings and shootings.
Local police sources in Mahmoudiya said the market was attacked with mortars, after which gunmen rampaged through it firing at shops and civilians.
One report said a Shia funeral procession was ambushed, prompting MPs from Moqtadr Sadr's Islamist faction to walk out of parliament.
The Associated Press agency reported that three Iraqi soldiers had been killed at a checkpoint in the town prior to the attack on the market.
Correspondents say the attack sent shock waves through the town, with frantic relatives involved in tense confrontations with security forces at the local hospital.
Late on Sunday, at least 23 people were killed in a suicide bomb attack in a cafe in the northern Iraqi town of Tuz Khurmatu, 170km north of Baghdad.
Police said the cafe was close to a Shia mosque in an area populated by Turkmen.
There are tensions between the Turkmen and Kurdish populations but the motive for the attack was unclear.
In the past 24 hours, almost 100 Iraqi civilians have been killed in violence across the country.
BBCLast Mod: 20 Eylül 2018, 18:16