China is taking an increasingly tough line on a border row with India amid a rising crescendo of nationalism in state media, and President Xi Jinping looks set for an awkward encounter with Prime Minister Narendra Modi at a multilateral summit next month.
Diplomats say Beijing would like to resolve the border issue before a summit of the BRICS nations - that also groups Brazil, Russia and South Africa - in the Chinese city of Xiamen in early September, and ensure nothing dampens what China wants to be a show of cooperation and friendship among developing countries.
But that could be tough. On Wednesday, China ramped up the rhetoric, accusing India of "concocting" excuses over the illegal entry of the South Asian nation's military into Chinese territory.
"China will take all necessary measures to safeguard its legitimate and lawful rights and interests," the Foreign Ministry said.
The two sides' troops are confronting each other close to a valley controlled by China that separates India from its close ally, Bhutan, and gives China access to the so-called Chicken's Neck, a thin strip of land connecting India and its remote northeastern regions.
Most previous standoffs, such as one in 2014 just ahead of a rare trip to India for Xi, were resolved with both sides withdrawing their forces. There has been no shooting since a brief border war in 1962.
Talks are happening behind the scenes, but with little apparent progress. Meantime, Chinese and India media have been taking a strident approach, with a Chinese state-run newspaper last week saying China could use force.
An Indian magazine's front cover last month showing a map of China shorn of Tibet and self-ruled Taiwan also ignited public anger on Chinese social media with thousands of angry posts.
"The problem is the media on both sides are whipping things up. This makes it hard for China or India to back down," said a Beijing-based source who is familiar with the discussions between the two sides.
The Indian government has asked political parties to refrain from politicising the issue and allow diplomacy to work.