Iraq’s chances of remaining a unitary state increased significantly with the signing of a new oil and budget agreement between the Baghdad government and the Kurds.

Building on a partial deal reached last month that permitted the Kurds to legally sell 150,000 barrels of oil a day through a pipeline to Turkey, the new agreement will allow the Kurdistan Regional Government (KRG) to sell 550,000 barrels of oil a day, including 300,000 from the disputed Kirkuk region. The KRG and the central Iraqi government will split the revenue.

The government of Prime Minister Haider al-Abadi also agreed to start paying the salaries of KRG employees again, a sum that amounts to 17% of the national budget or about $17 billion, and an additional $1 billion for weapons and salaries for the Kurdish peshmerga, which has proven to be a crucial force in battling the group that calls itself the Islamic State (IS).

Abadi’s predecessor, Nouri al-Maliki, alienated the Kurds by stopping the budget payments to the Irbil government and failing to reach an agreement over Kurdish oil exports. The KRG responded by accelerating production of its own oil and sending it to Turkey through a pipeline whose construction the Baghdad government had bitterly opposed. Much of the oil sat on tankers at the Turkish port of Ceyhan while the dispute between Kurds and Iraqis remained in stalemate.

IS spurred Kurdish push for independence

The rising threat of IS gave the KRG new leverage, however, especially after peshmerga forces seized the oil-rich city of Kirkuk. Without utilizing the KRG pipeline to Turkey, much of Kirkuk’s oil was stranded and could not be exported for the benefit of Iraqi or Kurdish authorities.

By last summer, KRG officials were openly threatening to hold a referendum on independence for their northern region, noting that the country’s map had changed with the IS capture of Iraq’s second largest city, Mosul, in June. However, the peshmerga also proved incapable of withstanding the IS advance without the intervention of U.S. airpower.

U.S. officials also pressed hard for an oil and budget agreement between Baghdad and Irbil. On Tuesday, State Department deputy spokesperson Marie Harf congratulated the “Iraqi and Kurdistan Regional Governments on reaching a broad agreement on revenue management and oil exports originating from the Iraq Kurdistan Region and Kirkuk. This resolution, in line with its constitution, allows all Iraqis to benefit equitably from Iraq’s hydrocarbon sector. This agreement will further strengthen both Iraq’s Federal Government and the Kurdistan Regional Government as they work together to defeat ISIL [another acronym for IS].”

Still much left to do to strengthen Iraq

Iraq is hardly out of the woods. Abadi is struggling to reach out successfully to Iraq’s third major constituency – Sunni Muslims – and to rebuild the Iraqi army with real soldiers, not “ghost soldiers” added to the rolls to facilitate corruption. The steady decline in oil prices makes his job even harder as there is less money to reconstitute the military and to lure Sunnis into joining local national guard units.

Still, the restoration of solid ties between Baghdad and Irbil is a prerequisite for Iraq to remain one country.

Exiled Iraqi Kurds and Shiites worked closely together in the 1990s to convince the U.S. to overthrow the regime of Sunni dictator Saddam Hussein and former exiles have been prominent members of the governments that followed the U.S. ouster of Saddam in 2003.

The latest agreement profited from the fact that KRG leaders know and respect the new Iraqi oil minister, Adel Abdul Mahdi.

At a recent energy conference organized by the Atlantic Council in Istanbul, Mahdi sat on the same stage with the KRG minister of natural resources, Ashti Hawrami, on a panel about Iraqi oil resources. The two referred to each other by their first names and were clearly on friendly terms.

Speaking at last month’s conference, Mahdi said that “all sides understand that [they] should work in a decentralized federal country” that shares revenues fairly and permits significant local autonomy.

Hawrami added, “this is probably our last opportunity between Baghdad and Irbil to get this right.”

With Tuesday’s agreement, the Kurds and Baghdad government are well on their way toward a new, more viable model for Iraqi governance. But there is still much to do to rid the nation of the IS menace and convince Sunnis that their future also lies within a united Iraq.

Barbara Slavin is a senior fellow at the Atlantic Council’s South Asia Center and a correspondent for Al-Monitor.com, a website specializing in the Middle East. She is the author of a 2007 book, Bitter Friends, Bosom Enemies: Iran, the US and the Twisted Path to Confrontation, and is a regular commentator on U.S. foreign policy and Iran on NPR, PBS, C-SPAN and the Voice of America.