Pakistan Army chief General Raheel Sharif visited Russia this week amidst a regional re-definition of old relationships. Russia, which fought against Pakistan-supported “mujahideen" during the earlier Afghan war in the 1980s, has been warming up to the South Asian country.

“In the last two years, we have had more high level visits between the two countries than in the past many years,” Tariq Fatemi, Pakistan’s minister of state for foreign affairs said in a policy speech.

“These have included ministers of power, energy, petroleum, finance, defense, foreign affairs, the army chief, and the chiefs of the other services,” Fatemi added

During his three-day stay in Moscow, General Sharif met the top Russian civil and military leadership. Pakistani Prime Minister Nawaz Sharif is also expected to travel to Russia in the next few weeks for a multilateral conference.

The two countries have announced plans to hold their first ever joint military exercise. Last year, Russia lifted its longstanding, self-imposed arms embargo to Pakistan to prepare grounds for the sale of defense related equipment.

“We have also signed an MoU between the two defense ministries and that we see an opportunity for acquisition of defense equipment from Moscow,” Fatemi elaborated during his speech.

This recent thaw between the cold war rivals is a “natural outflow of Russia’s concern about what is going to happen to Afghanistan after the withdrawal of the U.S.,” explained Nandan Unnikrishnan, who has served as Press Trust of India’s bureau chief in Moscow for several years.

If Afghanistan becomes unstable, the spread of militancy and Islamist radicalism is expected to spread to the weak states around it.

“The weak states are not China and Iran,” explains Center for Strategic and International Studies analyst Michael Kofman, who focuses on Russia and has worked on Pakistan.

Most of the Central Asian states around Afghanistan have porous borders, weak governments, and varying degrees of autocracies which makes them prone to instability or ethnic conflict. Militants from some of these states are already present in both Afghanistan and Pakistan.

“Frankly Tajikistan, Turkemenistan, Kyrgyzstan, these are all great targets, and Uzbekistan too,” Kofman said.

This is Russia’s backyard. Russia has a military presence in several of these countries and a large military base in Tajikistan.

Furthermore, there is a sizeable Muslim population inside Russia. So far the country has not faced issues of radicalization and militancy but it is not immune from them, particularly if the neighboring states fall victim to them.

Another reason for Russian overtures toward Pakistan may be to gain leverage with the Afghan Taliban via Islamabad in case the elected Afghan government falls.

“In the minds of Russian security services there is little doubt that Pakistani intelligence services and Pakistani establishment have very strong links with some of the Afghan Taliban,” according to Indian journalist Nandan Unnikrishnan.

Russia’s attempt at redefining its relationship with Pakistan comes at the risk of upsetting India, its traditional ally and largest defense sector customer.

However, Russia has justified this by pointing out that India has also looked to its rival, the United States, for its purchases. In the last few years, the U.S. has surpassed Russia to become India’s largest arms supplier.

Russia may also be looking to Pakistan as an untapped market. Pakistan’s direct defense trade with Russia has been limited, $22 million a few years ago compared to billions of dollars of trade with India.

Pakistan has usually received Russian equipment through China, which is not known for making aircraft engines and often uses Russian engines in its planes.

One of the benefits for Pakistan in trading with Russia will be “to cut out China as the middle man and save a lot of money,” according to Kofman of CSIS, who pointed out that Pakistan’s JF-17 Thunder aircraft, jointly developed with China, and recently in the news for receiving its first foreign order, uses Russian engines.

He also explained that the extent of this defense cooperation will depend on how much money Pakistan can spend.

“Russia, at the end of the day, is not in a position like the United States to subsidize defense deals,’ he said.

However, in a post Ukraine world of increased hostilities between Russia and the West, it is in Russia's interest to show that it is not isolated and has partners willing to do business with it.

Meanwhile, the United States has long encouraged countries in the region to take a greater interest in the stability of Afghanistan and has strongly supported China’s efforts in facilitating peace talks between the Afghan Taliban and the government of Afghanistan.

Many analysts think that at this point the United States is happy to have any actor that can contribute towards stability in Afghanistan, including rivals Russia and China.