BAGHDAD — A veteran Kurdish politician was elected president of Iraq on Thursday, as political leaders moved a step closer to forming a new government that will face the momentous task of repairing the deep divisions that are tearing the country apart.

Fouad Massoum received 211 of 269 votes in the Iraqi parliament after Kurds presented him as their candidate.

Under an informal power-sharing agreement, the role of president goes to a Kurd, the job of speaker of parliament to a Sunni, and the position of prime minister to a Shiite.

Massoum’s election starts the clock ticking on the thornier issue of choosing a prime minister, as pressure mounts on the incumbent, Nouri al-Maliki, to step aside.

Lawmakers now have 15 days to name a prime minister, according to the constitution.

The United States and other countries are urging Iraqis to move rapidly to form a new government after advances by the Sunni extremist group that calls itself the Islamic State. It has taken over large swaths of Iraq in an offensive that began last month.

While that battle has slowed into a stalemate, Islamic State has ramped up a bombing campaign in Baghdad.

Two car bombs blew up in the busy commercial district of Karrada on Thursday evening, killing at least 15 people, according to Al Sumaria television. The Associated Press put the death toll at 21.

The bombs went off near a Shiite congregation hall, residents said.

Earlier in the day, more than 50 prisoners were killed after an attack by the Islamic State in Taiji, 15 miles northwest of Baghdad, Iraqi security officials said.