The death of Saudi journalist Jamal Khashoggi is proving to be a blessing in disguise for cash- strapped Pakistani Prime Minister Imran Khan. Mr. Khan's blessing is also likely to offer Saudi Arabia geopolitical advantage.

On the principle of all good things are three, Mr. Khan struck gold on his second visit to the kingdom since coming to office in August.

Mr. Khan was rewarded for attending Crown Prince Mohammed bin Salman's showcase investors conference in Riyadh, dubbed Davos in the Desert, that was being shunned by numerous CEOs of Western financial institutions, tech entrepreneurs and media moguls as well as senior Western government officials because of the Khashoggi affair.

In talks with King Salman and the crown prince, Saudi Arabia promised to   deposit US$3 billion in Pakistan's central bank as balance of payments support and to defer up to US$3 billion in payments for oil imports   for a year.

Saudi Arabia declined Mr. Khan's request for financial aid during his first visit to the kingdom in September but was willing to consider investing billions of dollars in a refinery in the Chinese-operated Arabian Sea port of Gwadar as well as in mining but was reluctant to acquiesce to Pakistani requests for financial relief.

Saudi Arabia's subsequent agreement to provided finance is likely to help Mr. Khan reduce the size of the   US$8-12 billion bailout he is negotiating with the International Monetary Fund   (IMF).

Speaking in an interview before leaving for Riyadh, Mr. Khan said he was attending the conference despite the “shocking” killing of Mr. Khashoggi because “unless we get loans from friendly countries or the IMF, 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 .”

Pakistan's   foreign reserves dropped this month to US$8.1 billion, a four-year low   and barely enough to cover sovereign debt payments due through the end of the year. The current account deficit has swelled to about $18 billion.

Potential Saudi investment in the Reko Diq copper and gold mine as well as a refinery in Gwadar, both close to Pakistan's border with Iran would give it a further foothold in the troubled province of Balochistan. Gwadar is a mere 70 kilometres down the coast from the Indian-backed Iranian port of Chabahar.

Pakistani militants reported last year that   funds from the kingdom were flowing into the coffers of ultra-conservative anti-Shiite, anti-Iranian Sunni Muslim madrassahs   or religious seminars in the region. It was unclear whether the funds originated with the Saudi government or Saudi nationals of Baloch descent and members of the two million-strong Pakistani Diaspora in the kingdom.

It was equally unclear how Saudi Arabia expected to capitalize on its rewarding of Mr. Khan in its competition with Iran for Pakistan's favours.

Ensuring that Pakistan, home to the world's largest Shiite minority, does not snuggle up too much to Iran has become even more crucial for Saudi Arabia as it seeks in the wake of Mr. Khashoggi's death to enhance its indispensability to US President Donald J. Trump's effort to isolate and cripple Iran economically, if not to engineer a change of regime in Tehran.

Mr. Trump sees Saudi Arabia as central to his strategy aimed at forcing the Islamic republic to halt its support for proxies in Yemen and Lebanon, withdraw its forces from Syria, and permanently dismantle its nuclear and ballistic missiles programs.

Saudi financial support means that Mr. Khan may find it more difficult to shield Pakistan from being sucked into the US-Saudi effort.

Insurgents last week   kidnapped 14 Iranian security personnel , reportedly including Revolutionary Guards on the Iranian side of the border with Pakistan. Pakistan pledged to help liberate the abductees who are believed to have been taken across the border into Balochistan, long a militant and Baloch nationalist hotbed.

“Members of terrorist groups that are guided and supported by foreign forces carried this out through deceiving and bribing infiltrators,” the Guards said in a statement that appeared to blame Saudi Arabia and the United States without mentioning them by name.

The incident is likely to heighten Chinese concerns that in a worst-case scenario, Saudi investment rather than boosting economic activity and helping Gwadar get out of the starting blocks, could ensnare it too in one of the Middle East's most debilitating conflicts.

China is further concerned that there would be a set of third-party eyes monitoring activity if and when it decides to use Gwadar not only for commercial purposes but also as a naval facility.

Saudi investment could further thwart potential Chinese plans to link the ports of Gwadar and Chabahar, a prospect that Pakistani and Iranian officials have in the past not excluded. With Saudi financial aid, that may no longer be an option that Mr. Khan can entertain.

Mr. Khan will have to take that into account when he travels to Beijing next week in a bid to secure Chinese financial support and convince Beijing to fast forward focusing the China Pakistan Economic Corridor (CPEC), a US$45 billion plus infrastructure and energy generation-driven Belt and Road crown jewel, on issues such as job creation, manufacturing and agriculture.

Mr. Khan appeared to anticipate in his interview with Middle East Eye on the eve of his participation in the Riyadh investment conference that he would have reduced leeway by blaming the United States for increased tensions with Iran and   hinting that Pakistan did not want to be drawn into conflict with the Islamic republic .

Said Mr. Khan: “The US-Iran situation is disturbing for all of us in the Muslim world... The last thing the Muslim world wants is another conflict. The worrying part is that the Trump administration is moving towards some sort of conflict with Iran.”

Dr. James M. Dorsey is a senior fellow at the S. Rajaratnam School of International Studies, co-director of the University of Würzburg's Institute for Fan Culture, and co-host of the   New Books in Middle Eastern Studies  podcast. James is the author of  The Turbulent World of Middle East Soccer  blog, a  book  with the same title and a co-authored volume,  Comparative Political Transitions between Southeast Asia and the Middle East and North Africa  as well as  Shifting Sands, Essays on Sports and Politics in the Middle East and North Africa   and just published   China and the Middle East: Venturing into the Maelstrom.