Iraqi security forces opened fire and used tear gas on protesters who stormed into Baghdad's heavily fortified Green Zone on Friday for the second time within a month.
Dozens of demonstrators were injured by tear gas and live fire, witnesses told Reuters news agency.
Some security personnel were stabbed, according to a military statement. Authorities could not immediately verify reports that several civilians had been killed.
"Oh army, the country is hurt! Don't side with the corrupt!" the demonstrators chanted.
The thousands of protesters included supporters of Shia cleric Moqtada al-Sadr and people from other groups upset about the government's failure to approve anti-corruption reforms and provide security.
"Infiltrators exploited our forces' preoccupation with preparations for the Falluja battle to penetrate state institutions and cause chaos," the military said, referring to a city 50km west of Baghdad controlled by Islamic State of Iraq and the Levant (ISIL) for more than two years.
The government briefly imposed a curfew on Baghdad and authorities later said order had returned after what they called rioting at the Green Zone, which houses parliament, government buildings and many foreign embassies.
Al-Sadr, who did not explicitly call for Friday's demonstration, expressed support for protesters and condemned security forces' use of force against them.
"I respect your choice and your peaceful spontaneous revolt," Sadr said in a statement. "Curse the government that kills its children in cold blood."
Protesters occupied the cabinet building for several hours. Some held Iraqi flags and flashed peace signs near the insignia of the prime minister's press office and inside a meeting room.
The protesters eventually withdrew to Tahrir Square, but witnesses said security forces and unidentified gunmen opened fire there as well.
Supporters of al-Sadr and other groups have been protesting for months to demand reforms and an end to corruption and provide security. They had stormed the Green Zone on April 30.
They have added to their grievances the government's failure to provide security after a wave of bombings claimed by ISIL, which is also known as ISIS, in Baghdad this month which killed more than 150 people.
Iraq's political crisis broke out in February, when Prime Minister Haider al-Abadi announced plans to appoint a cabinet of independent technocrats, threatening to uproot a system of political patronage that makes the public administration open to corruption.
He has warned that the impasse could hamper Iraq's fight against ISIL, which continues to control territory in northern and western Iraq.