NEW DELHI — China’s leader, Xi Jinping, swept into India on Friday for a quick meeting with Prime Minister Narendra Modi. “Frenemies,’’ is how a senior Indian official has described the India-China relationship.

The two giant countries are neighbors and strategic rivals. They’re nuclear-armed, and their relationship is as complicated as ever. Mr. Xi and Mr. Modi are the most dominating leaders their nations have produced in decades, and both have outsize personalties. But with each other, they have no choice but to listen.

China wants to keep India from drifting closer to the United States, where Mr. Modi recently received a warm welcome from President Trump. India wants China to rebalance trade flows by buying more Indian good and services and to back away from the border disputes that have dogged their countries for years. A good relationship would help both countries in their aspirations to be world powers.

But it has been up and down for years. The two nations fought a short but intense war in the 1960s (China won) and have supported insurgencies in each other’s backyards and sparred over trade deficits (China is winning that one as well).