WHEN Japan’s prime minister, Shinzo Abe, belatedly took to Twitter, the first world leader he followed—and still one of the very few people he tracks—was his Indian counterpart, Narendra Modi. Periodically the two men engage in effusive courtship over the Twittersphere.

Much draws them together. Both are nationalist leaders of big Asian democracies, with a dark side that often rankles: Mr Abe has a tin ear when it comes to imperial Japan’s wartime atrocities, while Mr Modi averts his gaze from the Hindu bigotry of some of his devotees. Both want to assert the greatness of their countries by promoting growth-spurring reforms and closer military ties with the West. Both covet permanent seats on the UN Security Council. And though China remains their biggest trading partner, both want to counterbalance its military rise.

So when Mr Abe comes to India for a three-day official visit beginning on December 11th, the question will be whether the two leaders can move from flirtation to commitment. The likeliest concrete outcome of the visit will be an agreement for Japan to build a bullet-train line linking two of India’s most dynamic cities, Mumbai and Ahmedabad, the commercial capital of Mr Modi’s home state of Gujarat.

Two other possible deals would be more significant, and therefore contentious. One is an accord on civil-nuclear co-operation that would allow Japanese firms to bid to build nuclear-power stations in India. Japan regards itself as a champion of nuclear non-proliferation, yet an accord would give a Japanese seal of approval to India’s status as a nuclear-armed state. The second deal is a plan for India to buy and build Japanese seaplanes. It would amount to Japan’s first foreign sale of a military platform; the ShinMaywa US-2 planes are used for surveillance as well as search-and-rescue.

Mr Abe claims that the Indo-Japanese partnership is the world’s “most important bilateral relationship”. That sounds like flattery. The most important relationship for both Japan and India is obviously with America—not least for countering China. Yet the Indo-Japanese romance is certainly blossoming. This year Japan joined the annual Malabar naval exercises with India and America. Australia wants to join in, too. An earlier attempt at such multilateral war-games in the Indian Ocean was abandoned in 2008 after protests from China.

The resumption of such exercises betrays regional nervousness about China, particularly over its building of bases on contested reefs in the South China Sea. Under Mr Modi, India has for the first time declared an interest in freedom of navigation in the South China Sea. Last year the prime minister complained that “Everywhere around us, we see an 18th-century expansionist mindset: encroaching in other countries, intruding in others’ waters, invading other countries and capturing territory.” Few doubted that he meant China (and perhaps Russia, too).

“The geopolitical rapprochement between India and Japan has been nothing short of spectacular,” says Ashley Tellis, a former American diplomat now at the Carnegie Endowment for International Peace, a think-tank in Washington. That said, India’s tradition of non-alignment and Japan’s tradition of pacifism are still felt. Officials in Delhi are adamant that India will not join any formal alliance. “We can play with everybody. We are nobody’s camp-follower,” says one. Neither India nor Japan expects to come to the aid of the other should the shadowboxing with China ever turn into a real fight. Still, Mr Tellis argues that closer co-operation creates uncertainty for China. Its future operations could be greatly hampered if, say, India and Japan were to share intelligence on the movements of Chinese ships in or around the Strait of Malacca.

A love that knows some bounds

The Indo-Japanese love-in is unmarred by territorial disputes or historical resentment. During the second world war Japan was stopped before it could invade the British-run Indian subcontinent. Meanwhile, many Indians still admire Japan for offering shelter to fighters for Indian independence, notably Subhas Chandra Bose. Later, it is true, Japan and India drifted apart during the cold war. And after India detonated a nuclear bomb in 1998, Japan suspended much of its aid. But that is now all but forgotten.

If India’s non-alignment once meant a tilt towards the Soviet Union, its “all-alignment” of today is built on an ever-stronger partnership with America. In 2005 America signed with India a civil-nuclear co-operation agreement which, in effect, admitted India to the club of nuclear powers even though it has not signed the 1968 Nuclear Non-Proliferation Treaty. Warmer Indo-Japanese ties followed.

Economic links between India and Japan, by contrast, are still strikingly thin. Though India is the world’s seventh-largest economy, it accounts for no more than about 1% of Japan’s imports, exports and direct investments abroad. India missed out on the decades of Asia’s factory boom to its east. It remains outside the Asia-Pacific Economic Co-operation forum and the Trans-Pacific Partnership, a free-trade deal that America, Japan and ten other countries have just agreed upon.