Gunmen attacked a prisoner convoy north of Baghdad on Thursday, setting off a gunbattle with troops in which scores of prisoners and eight soldiers were killed, brutally underscoring Iraq’s instability as lawmakers convened to elect a new president.

U.N. chief Ban Ki-moon arrived in Baghdad earlier Thursday, urging lawmakers to “find a common ground” so they can address the crisis sparked by the rapid advance of the Islamic State extremist group and allied Sunni militants across much of northern and western Iraq last month.

At a press conference with embattled Prime Minister Nouri al-Maliki, Ban said Iraq is facing an “existential threat,” but one that could be overcome if it forms a “thoroughly inclusive government.” […]