During a three-day visit to Japan this week, Indian Prime Minister Manmohan Singh signed several major infrastructure and defense-technology deals, and agreed to speed up dialogue on nuclear cooperation and conduct more joint naval exercises. His host, Japanese Prime Minister Shinzo Abe, called Singh a “mentorlike leader.”

But the bonhomie appeared calculated, at least in part, to send a not-so-subtle diplomatic message to Beijing in the wake of a border row between India and China last month, as well as the dispute between Japan and China over resource-rich islands in the East China Sea.

The goal, analysts say, is to isolate China with a view to limiting its territorial ambitions in the region.

On Wednesday, Singh said India and Japan are “natural and indispensable partners” in efforts to bring about a “peaceful, stable, cooperative and prosperous future for the Asia-Pacific and Indian Ocean regions.”

Abe said the two democracies, “India from the west, Japan from the east,” must shoulder the important task of keeping Asia peaceful.

It is quite clear that all this is happening with China as the backdrop, because both Japan and India look upon China as a threat,” said Lalit Mansingh, a former Indian diplomat and strategic affairs analyst. “The Japanese prime minister wants to redefine the Indian Ocean and the Pacific region as a community of maritime democracies. That automatically excludes China . This is an important and clever move by India, too. I think Beijing has reasons to be worried.”

The message has not been lost on China.

On Tuesday, the Communist Party-controlled People’s Daily newspaper described China and India as natural partners, and hailed India’s “great wisdom” in handling its ties with China “in a calm way, undisturbed by internal and international provocateurs.” It also criticized recent visits by Abe to China’s neighbors to discuss ways to contain the superpower. “Some politicians just made themselves petty burglars on China-related issues,” it said.

Indian officials have portrayed Singh’s visit to Japan as a logical extension of India’s two-decade-old “Look East” policy of seeking closer relations with countries in East and Southeast Asia. After some dithering, India also appears to support the recent U.S. emphasis on a strategic pivot toward Asia, as a response to China’s rapid rise.

Abe has turned in recent times not only to India, but also to Southeast Asian countries to parry China’s influence in the region. He visited Indonesia, Thailand and Vietnam during his first overseas trip in office, and this week paid the first visit to Burma by a Japanese leader in 36 years.

Japan also is beginning to cooperate with countries that share concerns about China’s maritime ambitions, considering training Vietnamese submarine crews and helping bolster the Philippines coast guard.

India and Japan conducted their first joint naval exercise off the coast of Tokyo last year and this week pledged to deepen the cooperation with more.

“India, Japan join hands to break string of pearls,” read a headline in the Times of India newspaper Thursday, using the catchphrase for Beijing’s strategy of wooing Indian neighbors such as Pakistan, Sri Lanka, Bangladesh and the Maldives by establishing commercial and strategic facilities.

This week, Japan offered to lend $700 million to help build a new metro system in India’s financial capital of Mumbai, pledged to invest in India’s high-speed railway system and promised to supply advanced naval reconnaissance aircraft.

“Traditional Asian rivals Japan and China are at loggerheads again, and one country stands to gain the most from the chilly ties this time round: India,” the country’s Hindustan Times newspaper commented.

Harlan reported from Seoul.