Iraqi protesters retreated from the parliamentary building in central Baghdad early on Thursday morning after demonstrations against a candidate nominated by a group of Shiite parties.
The protesters, mainly supporters of Shiite cleric Moqtada Al Sadr, began to leave the building, located inside the heavily fortified Green Zone, after instructions from Mr Al Sadr telling them to return home.
"Your message has been received oh beloved ones, and you have terrified the corrupt," he said on Twitter. "You must now return safely to your homes."
Protesters were dancing and singing after storming the building, praising Mr Al Sadr and holding his pictures.
“We obey the Sayyed,” the crowds chanted as they calmly left parliament, a term honouring Mr Al Sadr by naming him as a descendant of the Prophet Mohammed.
Some were seen waving the Iraqi flag, walking on tables, sitting in the chairs of parliamentarians and looking through folders and papers.
Security forces were inside the building and they appeared to allow the protesters in with relative ease.
The demonstrations come with Iraq mired in a 10-month political deadlock as parties argue over forming a government.
They have failed to agree on a nomination for the posts of prime minister and president to establish a new Cabinet.
The demonstrators are against the recent nomination of Mohammed Al Sudani for the post of prime minister.
Mr Al Sudani held several positions in government since the US led invasion of 2003 and is known to be aligned with former prime minister Nouri Al Maliki.
He was officially nominated by the Co-ordination Framework bloc, a coalition led by Iran-backed Shiite parties and their allies.
Mr Al Maliki, who is considered the backbone of the framework, said early on Thursday that the storming of parliament was "a blatant violation" and called on protesters to retreat from the building.
Prime Minister Mustafa Al Kadhimi, who leads the caretaker government, called on demonstrators to “preserve public and private property” and to “listen to instructions of the security forces responsible for protecting them in accordance with the regulations and laws and to immediately withdraw from the Green Zone”.
Iraqi President Barham Salih said Iraq is going through delicate circumstances and the country faces huge challenges that require unity.
"Peaceful demonstration and expression of opinion is a constitutional right, with the need to adhere to laws, the maintenance of public security and property, exercise restraint," he said.
The United Nations mission in Iraq said the protesters have the right to peacefully express their opinion.
"The right to peaceful protest is essential to democracy. However, it goes hand in hand with respect for state institutions and the safeguarding of public and private property," it said in a statement.
"It is imperative that protests remain peaceful and in compliance with the law," the statement said.