Ahmed Rashid is a journalist and the author of five books on Afghanistan, Pakistan and Central Asia.

After decades of hostility, Russia and Pakistan are gingerly trying to improve relations. Russia is cautiously wooing Pakistan in a bid to temper Islamabad’s support for the Afghan Taliban and to end the civil war in Afghanistan, which is threatening Central Asia – the soft underbelly of Russian influence in the former Soviet Union territories.

Pakistan faces increasing isolation in the region – spurned by India, Afghanistan and Iran, and criticised by the US and NATO countries – because of its continued harbouring of the Afghan Taliban. At present, it is solely dependent on Chinese economic and political support.

It is not surprising, therefore, that Pakistan is desperately keen to rebuild relations with Russia. Islamabad would like to use warmer ties with Moscow to counter US and western pressure and be able to boast of more than one ally in the region.

Closer military cooperation

The actual signs of an improved relationship between Pakistan and Russia are still scant. In September 2016, 70 Russian and 130 Pakistani special forces held their first joint military exercises in Cherat, in northern Pakistan, home of Pakistan’s Special Forces. India had asked Russia to call off the exercise following the 18 September militant attack on an Indian army base which New Delhi blamed on Pakistan, but the Russians declined.

The military games went ahead and senior army officers from both countries visited the exercise.

Soon after, Pakistan offered Russia the use of Gwadar, its new Chinese-built port on the Gulf, which is close to Iran and opposite Oman. From Tsarist times, Russia has always wanted a port in the ”warm waters” of the Gulf. When the Soviets invaded Afghanistan, Pakistan was convinced that the Russian dream was to have a base on Pakistan’s Gulf coastline. Ironically, Pakistan is now offering the same facility.

However, Gwadar port is yet to become fully operational and it is surrounded by insurgencies in Afghanistan and Balochistan province. Its capacity is being enhanced by a Chinese-built network of roads that will eventually connect to the Chinese border in northern Pakistan.

Use of the port by foreign ships is still some way off, and Pakistan has not made it clear if it would allow Russian warships to dock there. The Chinese navy has already been granted landing rights at the port.

Russia has also agreed to sell helicopters to Pakistan, lifting its decades-old arms embargo against Islamabad, while India is now looking for arms from Western nations such as the US and France.

Historic divisions over Afghanistan

However, while the Pakistani government is playing up its new relationship with Moscow, the Russians are reacting cautiously, especially because of their long-standing relationship with Pakistan’s archenemy, India.

Russia cannot afford to annoy India, which is the largest market in the world for its arms and military aircraft. Historically, India was one of the few non-aligned Asian countries that sided with the Soviet Union during the Cold War. Both Russia and India are also providing Soviet-era arms and helicopters to the government in Kabul.

OPINION: Afghanistan is heading for civil war or worse

Earlier in March 2016 Prime Minister Nawaz Sharif made overtures to Russia for President Vladimir Putin to visit Pakistan, but the Russians said that they do not believe there was enough substance on the agenda to justify such a visit – a clear snub to Islamabad and a warning to do more to curtail the Taliban, who have twice captured the city of Kunduz that borders Central Asia.

No Russian president has ever visited Pakistan, but as long as the Taliban threaten Central Asia it is unlikely that a Russian leader will do so.

Afghanistan remains a key Russian interest. In April, Zamir Kabulov, Russia’s special envoy to Afghanistan, criticised the format of the peace talks that Pakistan was trying to bring about between the Kabul government and the Afghan Taliban. Russia was not happy it was sidelined in the talks, which included China, Pakistan, Afghanistan and the Taliban.

Kabulov called the talks inefficient and said Russia wanted to create a new format.

Nevertheless, Islamabad and Moscow are moving away from their years of hostility. In the 1980s, the Soviet Union occupied Afghanistan while the Afghan Mujaheddin were armed and financed by Western intelligence agencies and Pakistan’s powerful Inter-Services Intelligence. The Mujaheddin fought the Russians to a standstill, forcing it to withdraw from Afghanistan in 1989.

Throughout the 1990s, as Pakistan continued to support the Taliban regime in Kabul and the separatist uprising in Indian Kashmir, Russia remained wedded to its close ally, India.

The key to warmer ties is an end to the continuing civil war in Afghanistan. Both China and Russia feel threatened by this war, and by the number of young men from their Muslim populations who are joining militant groups. In an important development, Russia, China and Pakistan are due to hold a tripartite meeting to discuss the common threats they face in Afghanistan. Russia will host the meeting and Pakistan has already called it a watershed moment.

Russia and Pakistan also now share a common threat – that of the Islamic State of Iraq and the Levant (ISIL, also known as ISIS), which is recruiting youngsters in Russia, Central Asia, Pakistan and Afghanistan. The two nations may have a long way to go before relations actually warm up.

Ahmed Rashid is the author of five books on Afghanistan, Pakistan and Central Asia. His latest book is Pakistan on the Brink.

The views expressed in this article are the author’s own and do not necessarily reflect Al Jazeera’s editorial policy.