The blasts, one of which was the work of a suicide bomber driving a white van, struck as some 10,000 supporters of Asaib Ahl al-Haq gathered at the Industrial Stadium in eastern Baghdad for the rally of the Iranian-backed group. The afternoon event was organized to introduce the organization's candidates for Wednesday's vote.
An al-Qaida breakaway group, the Islamic State of Iraq and the Levant, claimed responsibility for the attack. It said in a statement posted on a militant website that the bombings aimed to avenge what it called the killing of Sunnis and their forced removal from their homes by Shiite militias.
The authenticity of the claim could not be independently verified.
The attack provided a stark reminder of the sectarian violence that's plagued Iraq more than two years after U.S. troops left the country, ending an eight-year presence that often served as a buffer between the nation's Shiite majority and its Sunni Arab minority.
Last year, the death toll in the country climbed to its highest levels since the worst of the country's sectarian bloodletting between 2006 and 2008. The United Nations says 8,868 people were killed in 2013, and more than 1,400 people were killed in the first two months of this year alone.
The resurgence of the sectarian violence is in part a reflection of the three-year-old conflict in neighboring Syria, where forces loyal to President Bashar Assad are battling mostly Sunni rebels whose ranks are dominated by Islamists or militants from al-Qaida-inspired or linked groups. Assad follows the Alawite faith, an offshoot of Shiite Islam. Asaib Ahl al-Haq, like Lebanon's Shiite Hezbollah, has sent fighters to Syria to join Assad's side in the civil war.
Two Associated Press reporters were covering the rally at the stadium when the blasts, spread over about 10 minutes, hit the complex. Intense gunfire rang out after the first explosion and continued throughout, giving the false impression that the rally was under attack by gunmen. The source of the gunfire was not known, but it is not uncommon for Iraqi security forces to fire in the air in the aftermath of major terror attacks.
Some of the attendees fled to a nearby building under construction in the stadium complex as female parliamentary candidates screamed and prayed for safety. Others ran out of the stadium in the chaos or took refuge behind the large stage erected for the occasion. Adding to the panic was the appearance overhead of a low-flying small aircraft that dropped election flyers before it hurriedly flew away.
The first explosion struck as men and women in colorful Arab medieval costumes were enacting a short play on the 7th century martyrdom in Karbala, Iraq, of the Shiites' most revered saint, Imam Hussein.
An AP driver said he was thrown back by the first explosion, then a second blast happened. He said guards around him began firing in all directions.
Another witness said he rushed out of the stadium along with his friends after the first explosion.
"I saw four charred bodies and several wounded people asking for help. There were also several damaged cars. Then, other blasts took place. People were in panic," said the witness, who gave his name as only Abu Sajad.
The rally was earlier addressed by Sheik Qais al-Khazali, a young cleric who had spent years in U.S. detention but was released after he was handed over to the Iraqi government. In his speech, he challenged the Sunni militants holding parts of two cities in Iraq's Anbar province, which is predominantly Sunni.
"We are ready and prepared to defend this nation," said al-Khazali, a one-time close aide of anti-U.S. Shiite cleric Muqtada al-Sadr. "Let it be known that Asaib will be the remedy."
Security guards jumped on al-Khazali after the first explosion, and then rushed him to his armored SUV.
The group remained defiant after the attack.
"This is a desperate act that will not stop us from moving on and challenging" the Sunni militants, said a senior Ahl al-Haq official, Wahab al-Taie. "They wanted to send us a message and they did, but that will not deter us."
Police and medical officials say the attack killed at least 31 people and wounded 37. They said the first two blasts were caused by bombs, but the third was the work of a suicide bomber. The officials spoke on condition of anonymity as they weren't authorized to release the information.
Followers of Asaib Ahl al-Haq carried out deadly attacks against U.S. troops before their withdrawal from Iraq in 2011 and claimed responsibility for the 2007 kidnapping in Baghdad of a British contractor along with his four guards. The group is backed by Iran and openly admits sending fighters to Syria to bolster Syrian President Bashar Assad's forces.
The top of the Baghdad stadium's terraces was adorned by images of Asaib Ahl al-Haq fighters killed in Syria.
"They fight Iraq's enemies there on the land of Syria," al-Khazali said, alluding to fighters in Syria.
The Islamic State of Iraq and the Levant and other Sunni militants frequently use car bombs and suicide attacks to target public areas and government buildings in their bid to undermine confidence in the Shiite-led government and target Shiite groups.
More than 9,000 candidates are taking part in Wednesday's elections and will vie for 328 seats in parliament. Parts of the Sunni-dominated Anbar province won't take part in the election due the clashes there between security forces and al-Qaida-inspired militants.
Associated Press writer Sameer N. Yacoub contributed to this report.