The 3 January attack on the Indian Consulate General in Mazar-e-Sharif, the capital of Balkh province in northern Afghanistan, has, once again, illustrated Pakistan's historic and continuing paranoia about the Indian presence in that country.
Balkh police chief Sayed Kamal Sadat has asserted with "99% certainty" that the attackers were "from the Pakistani military and used special tactics while conducting the operation".
As the Afghans have a long experience of facing Pakistan-trained terrorist groups, often intermixed with serving or retired military personnel, Sadat's comments cannot be taken lightly. Yet, India's Home Minister Rajnath Singh is unwilling to "distrust" Pakistan over the investigations and action it has promised into the Pathankot attack and .
There is little doubt that the attacks in Pathankot and Mazar-e-Sharif were linked. Through them, the Pakistani army sent multiple signals to Narendra Modi. For one, its anger at his barely-veiled accusation, at the inauguration of the new Afghanistan Parliament building, that Pakistan was providing nurseries and sanctuaries to terrorists attacking Afghanistan.
Modi had also made fun of Pakistan's charge that India was maintaining many more consulates than the official four in Afghanistan. Modi's speech was completely appropriate for the occasion. Pakistan fears being caught in an Indian pincer: directly from its eastern border and indirectly through an Indo-Afghan collaboration across its western border.
Pakistan has regularly accused India of fomenting trouble in Balochistan, where its own exploitative policies have sparked continuing insurgencies since 1947. Over the past few years, it has also accused India of assisting violent anti-Pakistan tribal groups in Khyber-Pakhtunkhwa.
To counter the so-called Indian threat via Afghanistan, Pakistan has traditionally wanted a government in Kabul that's sensitive to its concerns and reduces the Indian presence to a minimum generally, and to zero in the intelligence and security sector.
In addition, it has sporadically sent unmistakable signals by instigating attacks on Indian institutions and personnel in Afghanistan.
A concerted attempt was made during Nawaz Sharif's first term as prime minister in the early 1990s to achieve the first objective. The then Afghan president Najibullah, unable to keep the Mujahideen at bay any longer, left office.
A Mujahideen government was formed after Islamabad forced the Peshawar Agreement on Pakistan-based Afghan Mujahideen groups. A beaming Nawaz Sharif landed in Kabul a day after Sibghatullah Mojaddedi, the leader of one of the groups, became President. While Pakistan signalled victory, many Afghans deeply resented this "Punjabi" interference.
The Peshawar Agreement could not hold, however, and a civil war ensued. Pakistan took sides, supporting Gulbuddin Hekmatyar against Ahmed Shah Massoud. Meanwhile, Mojaddedi was replaced as president by Burhanuddin Rabbani, Massoud's leader.
The new Afghan government turned to India, Iran and Russia, among others, for support against Pakistan's interference. Clearly, Islamabad's plan to keep India out of Afghanistan had failed.
When it became obvious that Hekmatyar could not prevail over Massoud, Pakistan built up the Taliban. With the support of the Pakistani military, the Taliban captured Kabul in September 1996 and over the next two years took over almost 90% of the country.
However, Rabbani continued to be recognised by the United Nations as the legitimate president of Afghanistan and his government, informally called the Northern Alliance, maintained strong links with India. Thus, India remained influential though Pakistan succeeded in ensuring that it was essentially kept out of international diplomacy to bring the civil war to an end.
Then 9/11 happened. A US-led coalition threw out the Taliban, who retreated to Pakistan, which continued to support them. Not long after, Hamid Karzai became president and leaders of the Northern Alliance, who had close links with India, entered the government
Pakistan found itself on the margins in Kabul. There was deep popular resentment against it too. On the other hand, India was looked upon as a friend that had never interfered in the country's internal affairs.
Karzai's initial objective was to balance India and Pakistan. He urged Pakistan to give up its support of the Taliban and persuade them to negotiate with Kabul. When Pakistan refused to do so and did the opposite - it help the Taliban to recover such strength as to launch a major insurgency - Karzai turned to India for strategic support.
But that was not the only reason. Karzai's relations with the West had gone into a tailspin, so he needed a strategic partner. He turned to India as the first country with which Afghanistan signed a Strategic Partnership Agreement.
Pakistan was dismayed at India's growing presence in Afghanistan. It could not match the popular Indian Assistance Programme. Under the UPA, New Delhi limited its support for the Afghan Security Forces to training, but Pakistan sought to unsettle India and limit its role by attacking its diplomatic mission as well as those engaged in the Assistance Programme.
Indian assets in Afghanistan have been on Pakistan's radar since 2003. The three major attacks came some years later though. The Indian embassy was attacked in July 2008 by the Haqqani network; the Pakistan army was the sponsor. At least 58 persons were killed, mostly Afghans. The dead included the Indian defence attache Brigadier Ravi Datt Mehta and the counsellor Venketaswara Rao.
In October 2009, the embassy was again attacked and 17 persons were killed. A year later, two guest houses where Indian Assistance Programme workers lived was attacked. Among the dead were Indian army officers who were part of the programme.
India absorbed these attacks and continued its engagement, though in a less exposed manner. Significantly, it did not retaliate against these provocations. The UPA government also did not send lethal stores requested by Karzai under the Strategic Partnership Agreement.
In 2014, Modi came to power in May and in September, a National Unity Government was formed in Kabul with Ashraf Ghani as the president and Abdullah Abdullah as the chief executive.
The Indian Consulate General in Herat was attacked a few days before Modi's oath-taking ceremony, which Sharif attended. Fortunately the attack failed. Its purpose was to show Modi that the Pakistani army controlled the country's India policy and that India was exposed in Afghanistan.
Ghani has gone further than Karzai in seeking Pakistan's help in bringing the Taliban to the negotiating table. For this, he has been willing to downgrade relations with India. However, Pakistan's duplicity was evident when after the first meeting between the Taliban and Afghan representatives last July, it revealed that Mullah Omar was dead. It had withheld this information for a long time.
Ghani stands chastened and, urged by Abdullah, has opened up to India. But he continues to keep hope in the Pakistani army to deliver the Taliban.
The Mazar-e-Sharif attack was as much a warning to Ghani as it was to Modi. Will they see it as such?