WASHINGTON — There have always been irritants in relations between India and the United States. But few have been as perplexing to New Delhi, or left as bitter a taste, as President Trump’s tendency to mock Prime Minister Narendra Modi’s accent in English.

“There’s a general understanding here that Modi is not sure he can do business with Trump,” said Suhasini Haidar, foreign affairs editor of The Hindu. “India is just now coming to terms with the idea that Trump will not treat India with the same kind of benevolence that previous presidents have.”

This is the diplomatic headache that Secretary of State Mike Pompeo will confront when he arrives in the Indian capital on Wednesday with Defence Secretary Jim Mattis. Tiptoeing around the president’s indiscretions is one in a suddenly long list of challenges to a relationship that, according to senior State Department officials, Mr. Pompeo would very much like to preserve — and even improve.

Among the other challenges are growing trade tensions, American insistence that India suddenly end its huge purchases of Iranian oil, and Washington’s threats to impose sanctions should India continue to purchase Russian military equipment, as India has done for most of its history.

Improving ties with the United States was Mr. Modi’s signature foreign policy endeavour when he came to power in 2014. But with New Delhi suddenly uncertain about Washington, Mr. Modi has in recent weeks sought to mend ties with Moscow, and with Beijing as a hedge.

For decades, the United States hoped that India would become an economic and military counterweight to a resurgent China. Rex W. Tillerson, the Trump administration’s first secretary of state, described his outreach to India as among the most vital initiatives of his tenure, giving a gushing speech in October about the myriad reasons the two countries were natural partners.

Under Mr. Mattis, the Pentagon has been equally committed to the partnership. It has even renamed its Hawaii-based American combatant command that oversees the Pacific region as the Indo-Pacific Command as a lure for India to increase its partnership with the United States and other allied forces.

India’s rise was seen as such an obvious win for the United States that previous presidents mostly overlooked New Delhi’s reflexive trade protectionism. And if the Indians wanted to get some military equipment from Russia, that was seen as acceptable to Washington — as long as it meant India was becoming more powerful.

But under Mr. Trump, nobody gets a pass on trade. A congressional effort to punish Russia has meant that India’s plans to purchase a sophisticated air defense system from Moscow — the same one that President Recep Tayyip Erdogan of Turkey is considering buying — could seriously wound ties.

In some ways, Mr. Modi and Mr. Trump are made for each other. Both are right-of-centre nationalists who are seen by some minorities in each country as intolerant demagogues.

Mr. Modi is unsure he can do business with Mr. Trump, a foreign policy analyst said.CreditEdgar Su/Reuters

But a November summit meeting between them went poorly after Mr. Trump berated Mr. Modi over trade issues, particularly India’s tariffs on Harley-Davidson motorcycles. Mr. Trump’s decisions in recent months to impose sanctions on Iran and Turkey had spillover effects on India, pushing down the value of the rupee.

“The Americans are suddenly telling us that we can’t buy missiles and oil, and nobody knows what to do about it,” said Mohan Guruswamy, a distinguished fellow at the Observer Research Foundation in India.

Key positions at the State Department that deal with India remain vacant, adding to the uncertainty. And this week’s meetings were shelved twice before, with many Indians believing that the most recent cancellation was done at Mr. Trump’s insistence.

“The White House approach to every country now is that we want you to cave on these random issues we have chosen, which are prioritized by nothing more than presidential whim,” said Michael Green, a top Asia adviser to President George W. Bush. “And you have to visibly lose on them. There are no win-wins.”

Still, there is a good chance ties will continue to improve.

Walmart and Amazon are both investing billions of dollars in India. India’s purchases of American defence equipment are scheduled to top $18 billion by next year. Overall trade between the two countries hit $126 billion in 2017. And the number of Indian students in the United States soared last year to 186,000, the fourth consecutive year of double-digit growth.

As China becomes more assertive on its undemarcated border with India and ramps up investments in Sri Lanka, the Maldives and Nepal — all traditional Indian satellites — conviction has grown in New Delhi that it must counter Beijing forcefully.

Even Pakistan, India’s traditional rival, is increasingly being seen in New Delhi as little more than a Chinese proxy.

“The thinking inside and outside government has changed radically, with China now seen as our biggest threat,” said Lalit Mansingh, once India’s top career diplomat. “And if you look at China as a threat, you look around to see who can help us to defend against China. And it’s the U.S.”

But no one in the upper echelons of Mr. Modi’s government is quite sure how to deal with Mr. Trump, whose moods and demands even American diplomats seem unable to predict, Indians say.

Mr. Pompeo and Mr. Mattis must reassure the Indians without dismissing Mr. Trump’s concerns or promising that he will not latch onto some new concern — a test Mr. Tillerson failed.

“The erratic quality of this White House leaves everyone in the position not of trying to maximise the gains of the relationship, but instead trying to minimise the risks,” said Ashley J. Tellis, who was one of Mr. Bush’s top diplomats. “Everyone is struggling to deal with it, and India is no exception.”

Mr. Pompeo is also likely to stop in Islamabad for several hours to meet Imran Khan, Pakistan’s new prime minister. Relations between the two nations have grown so testy over the war in Afghanistan that the two sides have begun restricting the movement of each others’ diplomats. In addition, the American military is moving to withhold about $300 million in aid to Pakistan, citing insufficient actions against terrorist groups.