In a statement issued in Islamabad, the Foreign Office (FO) said that the agreement was reached on the eve of visit of Prime Minister Khan to Saudi to attend the high-profile Future Investment Initiative forum, nicknamed 'Davos in the desert', in Riyadh.
Prime Minister Khan held "detailed bilateral discussions" with the Saudi monarch, the statement said.
It said that far-reaching decisions on bilateral economic and financial cooperation were also agreed, including a MoU signed between Finance Minister Asad Umar and Saudi Finance Minister Muhammad Abdullah Al-Jadaan.
It was agreed that Saudi Arabia will place a deposit of USD 3 billion for a period of one year as balance of payment support, the FO said.
"It was also agreed that a one year deferred payment facility for import of oil, up to USD 3 billion, will be provided by Saudi Arabia. This arrangement will be in place for three years, which will be reviewed thereafter," it added.
The FO said Saudi Arabia also confirmed its interest to invest in a petroleum refinery in Pakistan and a "MoU will be signed after obtaining cabinet approval."
The kingdom expressed interest in development of mineral resources in Pakistan and a Saudi delegation will be invited to visit Pakistan after consultations.
Apart from attending the Future Investment Initiative conference, Khan also met Saudi Crown Prince Mohammad bin Salman to discuss matters of mutual interest.
Minister for Foreign Affairs Shah Mehmood Qureshi, Minister for Finance Asad Umar and other senior officials were also present during the meeting.
The crown prince agreed to Prime Minister Khan's suggestion to reduce visa fee for Pakistani workers, which is a significant step towards enhancing Pakistan's workforce in Saudi Arabia, as well as facilitating travel of people from both sides.
Khan has said that Pakistan would probably need loans from both friendly governments and the International Monetary Fund to meet its commitments.
Ahead of his visit to Riyadh, Prime Minister Khan said Pakistan must continue to prioritise good relations with Saudi Arabia despite the killing of dissident journalist Jamal Khashoggi because of the dire economic crisis facing the country.
Khan on Tuesday attended the investment summit that has been boycotted by many western officials and companies following the killing of Khashoggi inside the Saudi consulate in Istanbul on October 2.
Khan admitted that he could not afford not to attend the meeting.
Though shocked by Khashoggi's killing, Khan said his government needed urgent access to Saudi loans to avoid defaulting on record levels of debt within months.
"The reason I feel I have to avail myself of this opportunity [to speak to the Saudi leadership] is because in a country of 210 million people right now we have the worst debt crisis in our history, the cricketer-turned-politician was quoted as saying by the Middle East Eye, a London-based online news outlet.
"Unless we get loans from friendly countries or the IMF [the International Monetary Fund] we actually won't have in another two or three months enough foreign exchange to service our debts or to pay for our imports. So we're desperate at the moment," Khan said.
Khan is now scheduled to travel to Malaysia next week and to China on November 3 to seek financial assistance from the two friendly countries.
Pakistani media on Monday reported that the country immediately needed USD 12 billion to USD 13 billion to ease the financial crisis and retire foreign debt.
Pakistan formally approached the IMF on October 12 for a bailout to tide over the economic crisis.
But some tough talking by IMF Managing Director Christine Lagarde and the US on Pakistan's bailout plan, demanding absolute transparency on the country's debts, including those owned by China under the China-Pakistan Economic Corridor (CPEC) projects, has upset Islamabad.
Finance Minister Umar has said the government don't want to fully rely on the IMF. He said the loan programme with the IMF is almost final, but the government will have to see that the IMF does not place any "undoable conditions" for Pakistan in return.
The Foreign Office said Prime Minister Khan also addressed a Pakistan-specific session at the event where he underlined Pakistan's priorities towards optimizing the economy and attracting foreign investment.
"Stressing the focus of his government on human resource development, he highlighted the potential of Pakistan's youth, identified lucrative investment opportunities in the tourism sector, minerals, coal and gas exploration, and Information Technology," the FO said.
Khan mentioned the successes of Pakistan in the fight against terrorism, which has brought peace and stability to the country and elaborated the significance of China Pakistan Economic Corridor (CPEC), including the investment opportunities in the Special Economic Zones, it added.
The Prime Minister also took several questions from the audience comprising hundreds of business entrepreneurs.