Pakistan took a major step toward averting an economic crisis Thursday, reaching an initial deal with the International Monetary Fund on a bailout of at least $5.3 billion to help shore up the country’s rapidly diminishing foreign reserves.

The announcement should help calm fears of financial instability in Pakistan, a nuclear-armed nation of 180 million people that is also grappling with rampant violence by Islamic militants. But the deal mandates economic reforms that might be unpopular with Pakistanis.

Pakistan is a vital ally of the United States, which relies on Islamabad’s help to fight Taliban and al-Qaida militants and negotiate peace in neighboring Afghanistan. Analysts predicted pressure from the U.S., the most powerful member of the IMF, would be key to sealing a deal.

The agreement comes less than six years after Pakistan’s last IMF bailout, and the driving need for the money this time was to repay the institution nearly $5 billion that Islamabad still owes.

Pakistan’s previous government failed to implement many of the requirements of the last loan, including reducing the deficit and improving tax collection, and ended the program early. That left the new government, which took over at the beginning of June, with the difficult task of convincing the IMF that this time would be different.

The IMF mission director in Pakistan, Jeffrey Franks, acknowledged Islamabad’s checkered history, but said the institution would not punish the country for the failure of its predecessors.

“It is true that some previous programs have not been completely successful,” Franks said at a joint news conference with Pakistani Finance Minister Muhammad Ishaq Dar in Islamabad. “But the IMF is in the job of helping countries when they have difficult situations and need help, and we’re not going to turn a country down because previous governments did not do what they had promised to do.”

The $5.3 billion loan will be disbursed over a three-year period and will have an interest rate of roughly three percent, Franks said. It will be repaid over 10 years after an initial grace period of four years, he said.

The deal has been approved by the Pakistani government and IMF staffers in the country, but it still needs to be approved by IMF officials in Washington and the institution’s executive board. Pakistan would like the loan to be increased to $7.3 billion, but that is still under discussion, as is the precise timing of the disbursements.

The deal will be put before the IMF board in early September, assuming Pakistan first commits to key reforms designed to increase growth and improve financial stability, Franks said. Those include reforms needed to bring down the deficit, reduce pervasive electricity shortages and increase the country’s woeful tax collection.

This process differs from the last bailout, when the money was disbursed with the promise of reform that never ended up happening. Since 1988, Pakistan has signed onto eight IMF programs that demanded structural changes in the economy. But it has never managed to resolve its chronic problems.

“There will be some difficult decisions which the government is taking to get to that point of higher economic growth, reduced poverty and a better life for all Pakistanis,” Franks said.

Growth only has averaged three percent over the past few years, less than half the rate needed to supply jobs to Pakistan’s growing population.

Pakistan has already committed to some of the reforms this time around in the federal budget that passed last month, Franks said.

The deficit, which was roughly 9 percent of gross domestic product last year, will be brought down to around 6 percent this year and reduced to 3.5 to 4 percent by the end of the three-year program, Franks said. This will partly be done by restructuring and privatizing loss-making state-owned enterprises.

The government has committed to undertake steps to reverse Pakistan’s electricity shortages, which cause rolling blackouts of up to 20 hours a day in some parts of the country. The government will phase out costly subsidies that disproportionately benefit the wealthy, who use far more energy than the poor, said Dar, the finance minister.

It will also seek to lower the cost of producing electricity by converting fuel-powered plants to run on coal. The government spends about $1 billion in foreign currency each month to run its power plants, which has rapidly reduced the country’s foreign reserves.