BAGHDAD — Iraq’s president pledged Thursday that his office would draft a new electoral law and overhaul the country’s election commission — moves aimed at mollifying anti-government demonstrators clamoring for sweeping changes to the political order.

Barham Salih announced the measures in a televised address Thursday evening, saying that the government’s “legitimacy can come only from the people.” 

He said that to avoid a constitutional vacuum, Prime Minister Adel Abdul Mahdi, a focus of the protesters’ ire, would resign only if a replacement candidate were found. If the new electoral law is passed by parliament, Salih said, he would agree to early elections. 

The law, he said, would “allow for elections that are more just and better represent the people.”

Salih also pledged to form a new election commission made up of independent experts, including from the United Nations, to prevent fraud. 

It was unclear Thursday how quickly the changes would be implemented or whether Salih’s outreach would quell the widespread demonstrations that have erupted in Baghdad and cities in Iraq’s Shiite heartland in recent weeks.

Protesters first took to the streets earlier in October to demonstrate against corruption, high unemployment and a general lack of services. But as security forces cracked down on demonstrators — killing nearly 250 people — protesters widened their demands to include the resignation of the prime minister and the dissolution of powerful political factions, many of which are tied to Iran. 

“Everybody is throwing the ball into everyone else’s court,” Salam al-Jabiri, a 22-year-old protester, said in Baghdad after Salih’s address. “They think that this will buy them time.” 

“They don’t realize that this time it’s a revolution,” Jabiri said. “And we will stay here until we get rid of all of them — Abdul Mahdi, Salih and the whole parliament.”

The turmoil has caused rifts among the ruling class, including the two largest parliamentary blocs, one of them led by firebrand Shiite cleric Moqtada al-Sadr. The other bloc, Fatah, is the political arm of the paramilitary Popular Mobilization Forces and is led by Hadi al-Amiri, who is backed by Iran. 

Sadr called this week for Abdul Mahdi to resign and urged Amiri to join him in supporting a vote of no confidence against the prime minister. 

“If Prime Minister Adel Abdul Mahdi does not resign, Iraq could turn into another Syria or Yemen,” Sadr said on Twitter.

Demonstrators have lashed out at political parties and armed groups allied with neighboring Iran, which has maintained outsize political and military influence in Iraq since Tehran supported militias in Iraq’s battle against the Islamic State militant group. It has links to militants and politicians in Iraq and has mediated disputes among Iraq’s political and military factions. 

Iraqi protesters in recent days have burned Iranian flags and torn down posters of Iran’s supreme leader, Ayatollah Ali Khamenei. In the southern city of Karbala, a pilgrimage site for Shiite Muslims, demonstrators stormed the Iranian Consulate and raised the Iraqi flag. 

In a statement Thursday, the U.N. mission in Iraq condemned the “loss of life, the many injuries and the destruction of property.” 

The chief U.N. representative in Iraq also urged government transparency, saying Iraq is at a “crossroads.”

“Window dressing will only feed anger and resentment,” said Jeanine Hennis-Plasschaert, the special representative of the U.N. secretary general for Iraq.

Iraqi security forces, however, continue to use excessive and sometimes lethal force against largely peaceful demonstrators, human rights groups said. 

On Thursday, Amnesty International condemned the alleged use of military-style tear-gas grenades on protesters, some of whom it said were killed after being fired on at close range. 

“All the evidence points to Iraqi security forces deploying these military-grade grenades against protesters in Baghdad, apparently aiming for their heads or bodies at point-blank range,” Lynn Maalouf, Middle East research director at Amnesty, said in a statement. 

“The lack of accountability for unlawful killings and injuries by security forces, responsible for the vast majority of casualties this past month, is sending the message that they can kill and maim with impunity,” Maalouf said. “The authorities must rein in the police, ensure prompt, impartial, effective investigations, and prosecute those responsible.”