The International Monetary Fund has thrown Egypt a $12 billion lifeline.

Egypt desperately needs it. The economy has slumped since the Arab Spring in 2011. Political unrest and a series of currency devaluations have scared off foreign investors.

To make matters worse, terror attacks and aviation disasters have paralyzed its vital tourism industry.

According to the preliminary agreement released by the IMF on Thursday, Egypt will receive the emergency loans over the next three years. The bailout still has to be formally approved by the fund's board.

"Egypt is a strong country with great potential but it has some problems that need to be fixed urgently," said Chris Jarvis, the IMF's mission chief for Egypt.

Related: Egypt can't rely on cash-strapped Saudi Arabia

Moody's warned last month that Egypt's current account deficit had ballooned to a record 6.7% of GDP in the first quarter. That means the country is becoming ever more dependent on foreign money to pay its way.

But inflows of cash are drying up. And the central bank has been burning through its reserves of foreign exchange. They tumbled to $15.5 billion in July, down from $37 billion before the 2011 revolution.

Experts said the bailout will ease the pressure and may be followed by a further devaluation of the Egyptian pound as the government tries to help exporters and encourage Egyptians to buy local goods.

"The agreement with the IMF bodes well for the country's medium term growth prospects," said William Jackson, senior emerging markets economist at Capital Economics.

Related: Can Egyptian tourism survive another airline disaster?

Despite the turmoil, the IMF still expects Egypt's economy to grow by 3.3% this year and 4.3% next year. Inflation reached 14% in July. But that's a far cry from average growth rates of 6% seen before 2011.

The government is pushing through a series of reforms to boost growth and help the poor. It wants to introduce a sales tax and slash electricity subsidies. The plan is to spend the money raised on health and social programs.

The IMF said Egypt will invest in health insurance and medicine for the poor, develop better school meals programs and provide subsidies for food and infant milk.