BAGHDAD — Gunmen opened fire on anti-government demonstrators in the Iraqi capital late Friday, killing and wounding scores of people and unleashing scenes of chaos as protesters scrambled for cover.

The assailants approached demonstrators squatting near the main protest site in Tahrir Square, where thousands of Iraqis have camped out to call for sweeping reforms of the political system. They threw molotov cocktails and opened fire with assault rifles, witnesses said. At the same time, the power was cut and the surrounding area was plunged into darkness.

“Two cars came out of nowhere and then they started shooting. The electricity went off and it was dark and all we were hearing was the whizzing of the bullets,” said Ali Mohammed, 20.

“Lots of people were shot and we were running to find a safe place. The blood is still in the streets,” he said. “They were targeting us like we were terrorists.”

Two medical sources said that at least 12 people were killed. Security and medical officials told the Associated Press that as many as 15 people had died.

The spokesman for the Interior Ministry, Brig. Gen. Khaled al-Mahna, put the death toll at four and said that at least 80 people had been injured. Ministry officials were investigating the source of the gunfire, a separate statement said.

It was unclear who fired on the demonstrators. Protesters have occupied a swath of central Baghdad and sections of three bridges that lead to the Green Zone, which hosts Iraq’s parliament, as well as embassies and diplomatic missions.

Protesters are calling for a new election law and an end to the power-sharing system they say enriches Iraq’s political elite. The demonstrations and pressure from Iraq’s top Shiite cleric, Grand Ayatollah Ali Sistani, forced Iraqi Prime Minister Adel Abdul Mahdi to resign last week. Parliament has until Dec. 17 to choose a successor.

Since the protests began in October, at least 460 people have been killed in cities across Iraq, according to an official with the Supreme Human Rights Commission, a governmental body. He spoke on the condition of anonymity because he was not authorized to release figures to the media.

Amid the clashes late Friday, protesters in Tahrir Square used loudspeakers to call on people to join the demonstrations.

“We came here knowing we could die. We came here for our rights,” one demonstrator said.

On a street nearby, protesters dodging the gunfire broke into chants: “With blood and soul, we sacrifice for you, Iraq!”