Thousands of followers of Moqtada al-Sadr held a mass prayer outside parliament in Baghdad on Friday in a show of support for the powerful Shi'ite cleric who has called for Iraq's judiciary to dissolve parliament by the end of next week.

Supporters of the populist leader have occupied the Iraqi parliament since July after a 10-month political stalemate that followed elections last October. Sadr was the biggest winner but failed to form a government free of Iranian-backed parties.

He withdrew his lawmakers from parliament and is now preventing the chamber from electing a new government and is demanding early elections.

On Wednesday he said the judiciary must dissolve parliament by the end of next week. If not "the revolutionaries will take another stand", he said without elaborating.

Outside parliament on Friday thousands of Sadr supporters gathered for prayer. Most were dressed in black to mark the Muslim month of Muharram and some wore white capes symbolising burial shrouds and their willingness to die.

"You will not break Iraq as long as Sadr is here," an imam told the crowd from a big red stage set up outside parliament. "There is no going back from this revolution and the people will not give up their demands."

In the intense summer heat, men picked their way through the worshippers and sprayed them with cold water. Some carried portraits of Sadr and his father, also a prominent cleric, as well as Iraqi flags.

Iran-aligned political groups were expected to hold their own demonstration later on Friday, the latest in a series of protest and counter-protest in recent days which have led to fears of unrest.

Sadr counts millions of Iraqis among his followers and has shown he can still stir up gatherings by hundreds of thousands of supporters, mostly working-class Shi'ite Muslims, if he needs to exert political pressure.

His father Mohammed Sadiq al-Sadr was killed more than 20 years ago for his outspoken opposition Saddam Hussein. When Saddam was topped in a U.S.-led invasion in 2003 Sadr began an insurgency against U.S. troops.

His new foes, however, are fellow Shi'ite leaders and parties mostly aligned with Iran, as Sadr has positioned himself as a nationalist who rejects foreign interference. Those groups, like Sadr, are backed by heavily armed militias, but do not hold the same sway as he does over masses of fanatical followers.

(Writing by Dominic Evans; Editing by Ros Russell)