ISLAMABAD - As US influence in Islamabad wanes, Pakistan's former adversary Russia is building military, diplomatic and economic ties that could upend historic alliances in the region and open up a fast-growing gas market for Moscow's energy companies.

Russia's embrace of Pakistan comes at a time when relations between the United States and its historical ally are unraveling over the war in Afghanistan, a remarkable turnaround from the 1980s, when Pakistan helped funnel weapons and US spies across the border to aid Afghan fighters battling Soviet troops.

Though the Moscow-Islamabad rapprochement is in its infancy, and it is neighbor China that is filling the growing void left by the United States in Pakistan, a slew of energy deals and growing military cooperation promise to spark life into the Russia-Pakistan relationship that was dead for many decades.

"It is an opening," Khurram Dastgir Khan, Pakistan's defense minister, told Reuters. "Both countries have to work through the past to open the door to the future."

The cozier diplomatic ties have so far focused on Afghanistan, where Russia has cultivated ties to the Afghan Taliban militants who are fighting US troops and have historic links to Islamabad. Moscow says it is encouraging peace negotiations.

Both Russia and Pakistan are also alarmed by the presence of Islamic State (IS) inside Afghanistan, with Moscow concerned the group's fighters could spread towards central Asia and closer to home. In Pakistan, IS has already carried out major attacks.

"We have common ground on most issues at diplomatic levels," Pakistan's Prime Minister Shahid Khaqan Abbasi told Reuters. "It's a relationship that will grow substantially in the future."

During a trip to Moscow last month by Pakistan's foreign minister, Khawaja Asif, the 2 countries announced plans to establish a commission on military cooperation to combat the threat of IS in the region.

They also agreed to continue annual military training exercises that began in 2016 and followed the sale of 4 Russian attack helicopters to Pakistan, as well as the purchase of Russian engines for the Pakistan Air Force's JF-17 fighter jets that Pakistan's military assembles on its own soil.

The detente has been watched with suspicion by Pakistan's neighbor and arch-foe India, which broadly stood in the Soviet camp during the Cold War era. In the last 2 decades, the close Russia-India relationship has been underpinned by huge arms sales by Moscow to a country it calls a "strategic partner".

"If the Russians start backing the Pakistanis in a big way at the political level, then it creates a problem for us," said Sushant Sareen, a leading expert on India's relations to Pakistan and Afghanistan with New Delhi-based Observer Research Foundation.

India's foreign ministry did not respond to a request for comment on Russia's ties with Pakistan, but has previously said that its own relations with Moscow have stood the test of time, and that the two nations are building up defense and energy relations, including collaboration on nuclear reactors in India.

PIVOTING EAST

Steam rises from chimneys of a heating power plant in Moscow, Russia Monday. Maxim Shemetov, Reuters

Russian overtures to Pakistan offer a badly needed diplomatic lifeline for the South Asian nation as it faces growing friction with Western powers over its alleged links to militants.

At US urging, and with backing from Britain, France and Germany, a global financial watchdog, the Financial Action Task Force (FATF), last month decided to place Pakistan back on its watch list of countries with inadequate terrorist-financing controls, potentially hurting Pakistan's fragile economy.

The US move, which Islamabad angrily dismissed as an effort to "embarrass" Pakistan, followed Washington's announcement in January to suspend $2 billion in military assistance.

Asif, Pakistan's foreign minister, said his nation made a historical error by "tilting 100 percent" to the West and was now eager build alliances closer to home with the likes of China, Russia and Turkey.

"We want to correct the imbalance of our foreign policy over 70 years," Asif told Reuters. "We are not divorcing that relationship (with the West). But we want to have a balance in our relationships, we want to be closer to our friends in our region."

Defense minister Khan said Pakistan's military, which has historically been heavily reliant on US weapons and aircraft, may have no choice but to ramp up purchases from the likes of Russia.

The cooling relationship with Washington is already pushing Islamabad closer to China, which is investing about $60 billion in infrastructure in Pakistan. But analysts say Pakistan is wary of becoming overly dependent diplomatically on Beijing.

Pakistan is among several nations that have been courted by Moscow after falling out with Washington, including the Philippines and Qatar, but Russia's long-term aims for the Pakistan relationship are unclear, according to Petr Topychkanov, a senior researcher at the Stockholm International Peace Research Institute.

Russia last month appointed an honorary council in the Pakistan's northern Khyber Pukhtunkhwa province, where its companies are in talks to build an oil refinery and a power station.

But the biggest deals focus on gas supply and infrastructure to Pakistan, one of the world's fastest growing liquefied natural gas (LNG) import markets.

"On a strategic basis, Russia is coming in very fast on the energy side," said a senior Pakistani energy official.

In October, Pakistan and Russia signed an inter-governmental agreement (IGA) on energy, paving the way for Russian state-giant Gazprom to enter negotiations to supply LNG to Pakistan.

The talks are expected to conclude within three months and Gazprom is considered "one of the front-runners" to clinch a long-term supply deal, according to the Pakistani official. Based on two monthly LNG cargo deliveries, that deal would be worth about $9 billion over 15 years, he added.

There is also growing confidence that a gas pipeline due to be built by Russia, stretching 1,100 km (680 miles) from Lahore to the port city of Karachi, will go ahead.

US sanctions against Russian state conglomerate Rostec, as well as a dispute over North-South pipeline transport fees, have held up the $2 billion project since it was signed in 2015.