On 14 July, a day that will mainly be remembered by this generation for wicked horror on the streets of Nice in France, the Washington-based IMF released a 34-page document that constitutes the most ambitious attempt to remake a Middle Eastern economy.

The document sets out the programme Iraq has agreed to secure a $5.4bn IMF loan to fill a gap in its government finances, caused mainly by the fall in oil.

It also contains the reassurance required by international creditors who will soon be asked to provide additional loans. These are planned to include a $1bn government bond guaranteed by the US, a $1bn eurobond expected by the end of the year, a further $1bn from the Washington-based World Bank and more than $3bn in project loans.

The IMF says Iraq will need to borrow up to $56bn in the years up to 2019. This projection will come on top of the country’s existing debts, which the fund says totalled $67bn at the end of 2015. That is about 45 per cent of Iraq’s forecast 2016 budget.

The agreement’s main target, however, is the government’s fiscal deficit, which rose to 14 per cent of GDP in 2015. It is likely to increase further this year. Oil prices so far have averaged 75 per cent of their level in 2015 as a whole.

Baghdad has agreed the deficit should be reduced to 1 per cent of GDP in 2021. Some of this will be delivered by higher oil prices, which are forecast to rise to about $70 a barrel by the end of this decade.

But the bulk of the adjustment will come from spending cuts and government reforms.

For 2016, this will include tax rises, a cut in the public wage bill and pension payments, lower capital spending and reduced transfers to the Kurdistan Regional Government (KRG). The government has promised to execute 85 per cent of non-oil primary expenditure authorised in the 2016 budget.

In prospect is the introduction of value-added tax (VAT) and action to increase the efficiency of 176 non-financial state-owned enterprises, which employ 550,000 people. The agreement with the IMF says up to half are surplus to requirements.

This is a formidable programme. It compounds the challenge Iraq faces in driving the jihadist group Islamic State in Iraq and Syria (Isis) from its territory and dealing with more than 4 million people displaced in the northern regions since June 2014. About a quarter of a million Syrians have fled into Iraq since civil war erupted in Syria in 2011.

The world is rightly helping Baghdad to protect its people from internal terror and external threat. But they need hope that they can prosper as well. If the IMF deal does that, then it is a good thing. It looks, however, that things are going to get significantly worse before they get better.