Indian Prime Minister Narendra Modi has walked a careful line this week toward China, asserting that Delhi and Beijing must “work together” even as he announced a plan supported by the U.S. to develop a new Indian naval port in Indonesia aimed at countering China’s growing military and economic prowess.

With U.S. officials watching the developments closely, Mr. Modi said Friday that India and China must “rise above divisions and competition to work together” toward collective Asian prosperity.

The comments at the “Shangri-La Dialogue” in Singapore, which is being attended by U.S. Defense Secretary James N. Mattis, came a day after Mr. Modi said India will partner with Indonesia on the new naval port — a move likely to rankle Beijing at a moment when it is aggressively expanding its own regional maritime footprint.

Sources have told The Washington Times that U.S. officials have been working behind-the-scenes for months to urge India — a key U.S. security ally in the region — to take on a more bold naval posture and work with other American partners to signal to China that its expansionist activities won’t go unanswered.

With that as a backdrop, Mr. Modi is engaged in a kind of balancing act between the U.S. and China, who are in competition as India’s top international trading partners. The Indian prime minister and Chinese President Xi Jinping had a positive meeting in China in late-April, according to the Times of India, which said the two exchanged views on solidifying the Delhi-Beijing relationship.

But U.S. officials have expressed concern publicly about the need for India to play a more central role in responding to China’s fast-moving One Belt One Road initiative, through which Beijing has been pumping cash into infrastructure projects to buy access to resources around the region. The Trump administration has argued the initiative — laden with billions of dollars worth of China-funded projects in countries on every side of India, from Sri Lanka to Nepal to Pakistan — lacks transparency and is saddling those nations with “predatory debt.”

Beijing has also spent recent years building up bases in the disputed waters of the South China Sea and has been sending submarines and warships, in coordination with the One Belt One Road initiative, to far-flung China-financed ports in Sri Lanka and Pakistan.

The situation has concerned many in India’s national security sphere, who say the moment is ripe for the U.S. and India to get serious about expanding their current military-to-military naval alliance to make clear who controls the Indo-Pacific.

“China’s activities create a large amount of impetus for a more focused and more action-oriented India and U.S. navy-to-navy, maritime-to-maritime, country-to-country engagement,” former Indian Vice Adm. Pradeep Chauhan told The Times at a recent U.S.-India conference in Delhi.

U.S. officials say Mr. Mattis will seize on the Shangri-La Dialogue currently taking place in Singapore to push the message that the U.S. intends to challenge China on the high seas and will use its Navy to push back against Beijing’s maritime expansion.

Mr. Mattis told reporters this week that a “steady drumbeat” of American naval activity in and around the South China Sea will serve to push back against China’s efforts to claim territory in the region. He declared that China is “out of step” with international law and is failing to respect international waters.

“We are going out of our way to cooperate with Pacific nations. That’s the way we do business in the world,” Mr. Mattis said. “But we are also going to confront what we believe is out of step with international law, out of step with international tribunals that have spoken on the issue, and part of this is we maintain a very transparent military activity out in the Pacific.”

Mr. Modi, meanwhile, pushed a similar but notably more conciliatory message toward China on Friday.

“India stands for a free, open, inclusive Indo-Pacific region, which embraces us all in a common pursuit of progress and prosperity,” the Indian Prime Minister said, according to the Times of India, which also reported on Mr. Modi’s announcement of the joint naval port plan for Indonesia.

“We believe that our common prosperity and security require us to evolve, through dialogue, a common rules-based order for the region,” Mr. Modi said. “Competition is normal. But, contests must not turn into conflict; differences must not be allowed to become disputes.”