The integrity of Iraq and its stability depends on satisfying these demands. That requires a robust economy that depends on oil revenue.

The accord will have serious bearing on the territorial integrity of Iraq. Oil can either divide the country or keep it together. The question is how to share the oil revenue and how to finance the demands of the Sunnis, Shiites and Kurds. Shiites want the government to invest in oil-producing areas under their control. Sunnis want a national guard to be set up to protect them from the Islamic State. Kurds want 17% of the oil revenue of the government and for the government to pay the salaries of peshmerga fighters.

It wasn’t for nothing that Iran, the United States and Europe worked so hard for this accord that has important ramifications for future of Iraq. The same accord will have important consequences for Turkey.

The agreement that Iran, the United States and Europe have been pushing for months was finally signed last week when Erbil and Baghdad agreed to regulate their oil production and revenue sharing.

Baghdad will pay Erbil its due allotments from the federal budget and will meet the salaries of peshmerga. This will certainly give Kurdistan Regional Government President Massoud Barzani, who has not been able to pay the salaries of public servants for months and who has been borrowing from Turkey, some breathing room.

The accord signed last week does not only regulate the sharing of oil revenue but also proposes ways of generating new revenue from oil. The intention is to fill the coffers of both Baghdad and Erbil.

By signing the accord, Kurds are not only promising to share their oil revenue with Baghdad but also postponing their dreams of an independent Kurdistan. This no doubt pleases the United States and Iran, which have opposed the idea of an independent Kurdistan and insisted instead on the territorial integrity of Iraq. Even Europe can benefit if Baghdad and Erbil act jointly to meet the natural gas demands of Europe. This in turn may reduce Europe’s dependence on Russian natural gas.

As for the implications of the Baghdad-Erbil accord for Turkey, that is a bit complicated. For both parties, to reach an accord means the end of an important stumbling block for Turkey. Turkey had signed oil agreements with the Kurdistan Regional Government (KRG) without seeking the blessing of the Baghdad government. Kurds ship their oil to Turkey's Ceyhan port via a pipeline they built on the area they control. Kurdish oil is then marketed from there. Baghdad has furiously objected that this violates the Iraqi constitution, and that Kurds cannot sell oil on their own and that legal action may be initiated.

Turkey came up with some creative solutions to avoid Baghdad’s reprisals. Oil agreements with the KRG were made with a private company. Kurdish oil revenue was deposited in a Turkish bank, and Kurds were given 17% of the revenue until they reach an agreement with Baghdad.

All these complications will end with the signing of the Baghdad-Erbil accord. Oil trade between Turkey and Kurds will continue without threats from Baghdad. Turkey will buy its oil cheaper and will be taking another step toward its dream of becoming an energy hub.

That is all fine, but there is a potentially less promising aspect to it. For the past few years, Barzani has been a dependable ally for Turkey. He supported Turkey’s policies of opening to the Kurds, to limit the regional influence of the Kurdistan Workers Party (PKK) and to weaken the position of the Democratic Union Party (PYD) in Syria. He did all this, though he was still accused of being Turkey’s stooge.

The basic cause of Barzani’s amazingly close ties to Turkey has been his problems with Baghdad and the arising economic bottlenecks. For Barzani to extricate himself from the economic bottleneck was to sell Kurdish oil to the world via Turkey.

The accord signed last week might change the situation. Baghdad will be giving Erbil its agreed share from the federal budget. It will pay salaries of peshmerga. In sum, Baghdad-Erbil tensions may well end with this accord.

No doubt, trade with Turkey is still vital for Erbil. But Turkey is no longer the only hope for Kurds. The money coming from Baghdad will expand the room for maneuver of Kurds.

What does this mean for Turkey? Barzani might not be as willing and cooperative as he had been to do everything as Turkey wants. He may not still play the active role in Ankara’s Middle East policy.

A Barzani who depends on the United States and Iran for his security, on the West for building energy infrastructure and on Baghdad to overcome the economic bottlenecks will no longer be totally in Ankara’s hands.