BAGHDAD—The Iraqi government agreed Tuesday to an oil export deal with the northern region of Kurdistan, signaling an end to a yearslong political impasse that has nearly bankrupted both governments and hobbled efforts to fight the Islamic State insurgency.

The broad deal would allow Baghdad and Erbil, the capital of the Kurdish Regional Government or KRG, to mend broken relations that have put the defense of the country against Islamic State on shaky ground. The accord is also likely to further muffle voices in Iraqi...