The last time Xi Jinping ( 習近平 ) visited India, two years ago, Narendra Modi made an unprecedented gesture of receiving the Chinese leader in his home state of Gujarat rather than the capital, Delhi. They signed billion-dollar deals, sat on a swing at a riverside park, smiled at each other, and the shutterbugs went nuts.

There was hope in the air. Modi, freshly elected as India’s prime minister, was being widely hailed in the Chinese media as a possible Indian Nixon ­– a man with both the mandate and the personality to reset a fraught relationship.

Xi, the most powerful Chinese leader since Mao, was seen as the one who could put a lid on the thorny border issue that has bedevilled relations between the two Asian giants. But by the end of that three-day visit, the mood had swung back to the usual suspicion and hostility, with reports pouring in of Chinese and Indian soldiers facing off on the border.

This time, even before Xi has touched down in Goa to attend a BRICS (Brazil, Russia, India, China and South Africa) meeting at the weekend, the mood has been decidedly sour and the air acrid with the whiff of gunpowder though Diwali, India’s festival of lights, is a fortnight away. It’s trouble at the border again, this time between India and Pakistan. But Asia’s tangled borders and unique geopolitical tangos mean China is enmeshed in it anyway.

How India-Pakistan tensions (and US-China rivalry) are raising nuclear stakes

Last month, a terror strike on an Indian army camp by militants from across the disputed border with Pakistan left 18 soldiers dead. Within days Delhi announced its commandos had crossed over to the Pakistani side and taken out terror camps and militants in what it called “surgical strikes”.

The subcontinent has since been in a state of war frenzy, sizzling and seething with rage but not being able to do anything about it – because an all-out war is out of the question between the two nuclear-armed neighbours. One Indian television channel has even created a “war room”, with its anchor dressed in battle fatigue.

Why China is caught in India-Pakistan crossfire

It is this bottled up rage that Xi is flying into, his guilt in Indian eyes established by his association with Pakistan. If the “all-weather” friendship between China and Pakistan were not enough, a spate of Chinese decisions on the heels of the border fireworks – either poorly timed or intentional – have only strengthened the perception of unflinching Chinese support of a rogue state bent on harming India.

“Xi’s visit takes place against the backdrop of some serious Indian dissatisfaction with the Chinese over a number of issues and a perceived failure of the Chinese to rein in their ally. Why China should bother to rein in Pakistan when really the problem is as much with India’s Pakistan policy is a question that does not seem to be asked often enough in India,” said Jabin Jacob, a fellow at the Institute of Chinese Studies in New Delhi.

“The Chinese have merely exploited India’s weakness. Even the US has, but of course nobody here criticises the US. Be that as it may, Modi will be his usual gracious self in public and is likely to be sending out a tough message in private.”

Soon after the attack on the Indian army base and the subsequent mortar shelling between Indian and Pakistani troops along the border, China again stalled India’s efforts to get Pakistan-based Jaish-e-Mohammed chief Masood Azhar designated as a terrorist by the United Nations, letting him off the hook for another six months.

Jaish is considered to have engineered the recent attack on the Indian military base and an Indian airbase in January. India in March moved a resolution at the UN to designate Azhar a terrorist. China, a veto-wielding permanent member of the UN Security Council, was the only country in the 15-nation body to put a “technical hold” on the resolution then, and it extended the hold this month.

Pakistan fury after India conducts 'surgical strikes' on militants preparing cross-border terror mission

China’s support for Azhar coincided with news of China blocking off a tributary of the Brahmaputra river, which flows through China, India, Bhutan and Bangladesh, as part of a major hydroelectric project. Since that move followed reports that India was considering revisiting the water-sharing arrangements of the Indus river – which flows through China, India and Pakistan – as a way of punishing water-stressed Pakistan, it was quickly seen as China’s way of telling India not to use the Indus against Pakistan.

With the ties between China and India already under strain since China in June blocked India’s entry into the Nuclear Suppliers Group, which would give India a bigger role in nuclear commerce, this cocktail of adversarial moves by China has created the perfect storm of anti-Chinese sentiment in India. The most visible sign of the rage is evident in the growing social media campaign to boycott Chinese goods. #BoycottChinaProduct [sic] and #BoycottChineseGoods have attracted thousands of tweets, including several leaders from Modi’s Bharatiya Janata Party (BJP). The campaign comes during the Diwali season, when people in many parts of India exchange gifts. Most of these gift items, and increasingly Diwali crackers, now come from China.

As India’s largest trading partner, shutting out China from the economy, however, is not feasible. Especially since the government itself has no intention of slowing down the growing economic interaction. At the fourth India-China Strategic Economic Dialogue this month, the two sides agreed to cooperate in fields ranging from energy and railway to coastal manufacturing zones.

An influential section of the government, in fact, wants deeper engagement with China, posing a difficult balancing act for Modi between economic prudence and public opinion. While Modi understands the need for Chinese investment – which has grown 400 per cent in two years – and Chinese market access, China is looking to play a bigger role in the prized Indian market as its own slows down.

It is this mutual economic interest that still keeps the relationship at the leadership level on an even keel. “Warm economics and cold politics,” is how Jiang Jingkui, director of the South Asia Research Centre at Peking University, described the current state of relations to India’s Hindustan Times.

Indian Prime Minister Narendra Modi takes aim at Pakistan and governments ‘inspired by terrorism’

“China is not giving up on Modi. He’s still just halfway into his term and a lot can change,” said Sourabh Gupta, senior fellow at the Institute for China-America Studies in Washington, adding that India’s independent and restrained position on the South China Sea compared with much of Asia was still a source of comfort for Beijing.

“Basically, China is for the most part biding its time on Modi. To China’s credit, it has not responded to India’s deeper defence relationship with the US with pressure on the boundary. When Modi is ready to deal with China, China too will be ready to deal and produce. Until then, China will bide its time and hope not to get too sucked into India’s antagonism towards Pakistan.”