Four Iraqis were killed on Monday after powerful Shi'ite Muslim cleric Moqtada al-Sadr said he would quit politics, prompting his loyalists to storm a palatial government complex in Baghdad and leading to clashes with backers of rival Shi'ite groups.

Young men loyal to Sadr charged the government headquarters in Baghdad's secure Green Zone, once a palace of dictator Saddam Hussein, and took to the streets outside the area where they skirmished with supporters of rival Tehran-backed groups.

As gunfire echoed over the capital, some people were seen firing guns towards the ranks of supporters of Sadr, Reuters witnesses said, while others fired into the air in a nation awash with weapons after years of conflict and unrest. Supporters of rival groups also hurled rocks at each other.

The flare-up followed a political deadlock lasting months that has blocked the formation of a new cabinet. The army swiftly ordered a curfew.

In addition to the four people killed, several dozen were injured, police and medical workers said.

"I hereby announce my final withdrawal," Sadr had announced earlier on Twitter, criticising fellow Shi'ite political leaders for failing to heed his calls for reform.

The clashes erupted hours after that declaration, prompting his supporters, who had already been staging a weeks-long sit-in at parliament in the Green Zone, to demonstrate and storm the main cabinet headquarters. Some jumped into a swimming pool at the palace, cheering and waving flags.

Iraq's military declared an open-ended nationwide curfew and urged the protesters to leave the Green Zone.

During the stalemate over forming a new government, Sadr has galvanised his legions of backers, throwing into disarray Iraq's effort to recover from decades of conflict and sanctions and its bid to tackle sectarian strife and rampant corruption.

Sadr, who has drawn broad support by opposing both U.S. and Iranian influence on Iraqi politics, was the biggest winner from an October election but withdrew all his lawmakers from parliament in June after he failed to form a government that excluded his rivals, mostly Tehran-backed Shi'ite parties.

Sadr has insisted on early elections and the dissolution of parliament. He says no politician who has been in power since the U.S. invasion in 2003 can hold office.

IMPASSE

In Monday's announcement, Sadr said he would close his offices, without giving details, although he said cultural and religious institutions would remain open.

Sadr's decision ramped up dangerous tensions among heavily armed Shi'ite groups. Many Iraqis worry that moves by each Shi'ite camp could lead to new civil conflict.

"The (Iran) loyalists came and burned the tents of Sadrists, and attacked protesters," said Kadhim Haitham, a supporter of Sadr.

Pro-Iran groups blamed the Sadrists for the clashes and denied having shot at anyone. "It's not true - if our people had guns why would they need to throw rocks?" said one militia member, who declined to be identified by name.

Sadr has withdrawn from politics and the government in the past and has also disbanded militias loyal to him. But he retains widespread influence over state institutions and controls a paramilitary group with thousands of members.

He has often returned to political activity after similar announcements, although the current deadlock in Iraq appears harder to resolve than previous periods of dysfunction.

The current impasse between Sadr and Shi'ite rivals has given Iraq its longest run without a government.

Supporters of the mercurial cleric first stormed the Green Zone in July. Since then, they have occupied parliament, halting the process to choose a new president and prime minister.

Sadr's ally Mustafa al-Kadhimi, who remains caretaker prime minister, suspended cabinet meetings until further notice after Sadrist protesters stormed the government headquarters on Monday.

Iraq has struggled to recover since the defeat of Islamic State in 2017 because political parties have squabbled over power and the vast oil wealth possessed by Iraq, OPEC's second-largest producer.