Saudi Arabia has agreed to give Pakistan $3 billion in foreign currency support for a year and a further loan worth up to $3 billion in deferred payments for oil imports to help stave off a current account crisis, government said on Tuesday.

The $6 billion total exceeds forecasts by analysts and will likely reduce the size of any bailout Pakistan it receives from the International Monetary Fund (IMF), with whom it is currently engaged in talks on a rescue package.

The Saudi agreement came as Prime Minister Imran Khan attended a Saudi investment conference that has been boycotted by several other leaders over the death of a dissident Saudi writer at the country’s consulate in Istanbul.

Khan had said before departing that the country is “desperate” to shore up its foreign currency reserves, which are at a four-year low, equivalent to less than two months’ imports and barely enough to make its debt repayments through the rest of the year.

Finance Minister Asad Umar this month requested talks with the IMF for the country’s second bailout in five years. An IMF team is due to visit Pakistan to open negotiations on Nov. 7.

Khan had however sought to avoid going to the IMF and still wants to at least reduce the size of any bailout by appealing to “friendly countries” for bilateral financial support.

The Foreign Ministry on Tuesday night said the latest visit had met with success.

“It was agreed Saudi Arabia will place a deposit of $3 billion for a period of one year as balance of payment support,” the ministry said in a statement.

“It was also agreed that a one year deferred payment facility for import of oil, up to $3 billion, will be provided by Saudi Arabia. This arrangement will be in place for three years, which will be reviewed thereafter.”

The PM is scheduled to visit China next week.

The officials have been concerned the United States, which has fallen out with Islamabad, will push the IMF to impose harsh conditions on the country as part of any bailout.

Analysts say reducing the size of the bailout package needed from the IMF would shore up country’s weak position during negotiations with the fund.