By Vibhuti Agarwal and Krishna Pokharel

NEW DELHI -- A deadly clash with China high in the Himalayas has posed a tricky domestic challenge for Indian Prime Minister Narendra Modi, who has cultivated an image as a strong nationalist leader and struggled to deliver on promises to transform India's economy.

The showdown has stoked the sort of nationalist feelings that Mr. Modi has proved adept at turning into political support, but unlike past confrontations with Pakistan, India can't afford to turn China into an archenemy, analysts say.

"Nationalism is all right to rally people to your support," said Subramanyam Chandrasekharan, director of South Asia Analysis Group, a New Delhi-based think tank. But, he said, "You have to be careful. It's a double-edged sword. The situation can only be solved diplomatically."

Mr. Modi responded to the border clash by banning 59 Chinese smartphone apps, including the wildly popular short-video app TikTok, citing cybersecurity concerns.

Still, India has continued negotiating to de-escalate tensions on the border. Chinese and Indian troops both started to withdraw from some friction points in disputed areas along the two countries' Himalayan border, Indian security officials said this week, following talks between senior diplomats and military commanders to calm tensions.

"Never in history has expansionism been successful for those who tried it," Mr. Modi told Indian forces during a visit last week to Ladakh, part of the disputed border region. "Today, the world is dedicated to development. India will always focus on this."

The clash with Asia's fastest-rising power has come after a storm of bad news for Mr. Modi and his Bharatiya Janata Party. They were voted into power in 2014, then re-elected last year, based in large part on confidence that Mr. Modi could build a stronger, more stable India and raise the standard of living for its many poor citizens.

Mr. Modi, who built his political resume overseeing Gujarat, one of India's most economically vibrant states, pledged to add trillions of dollars to India's gross domestic product.

Instead, growth began to sputter a few years into his first term. It entered a sharp downturn last year and has now collapsed with the disruption caused by the coronavirus pandemic.

Growth slipped to an 11-year low in the 12 months through March and economists predict it will contract for the first time in 40 years this year.South Asia, led by India, could be the region worst hit by the pandemic globally, with possibly more than 100 million people pushed back below the poverty line, according to a study at the United Nations University World Institute for Development Economics Research.

Despite one of the world's tightest lockdowns, India has become one of the countries suffering the most from the virus, trailing only the U.S. and Brazil in the total number of cases. Its biggest cities are struggling to contain the spread, and health experts say it could be months before the number of infections peaks.

All of that comes after a wave of antigovernment demonstrations swept the country last year protesting the BJP's change in a citizenship law that many saw as undermining the country's commitment to diversity and religious freedom.

"Modi's image has taken a serious beating" domestically, said Bibhu Prasad Routray, director of Mantraya, an Indian strategic think tank.

Still, Mr. Modi's popularity remains remarkably high, with 74% of Indians expressing approval of his leadership in a poll conducted in late June by U.S. polling and research company Morning Consult.

Many Indians appreciate the extra cash and food handouts the government has distributed during the pandemic.

Kavita Kumari, 32, lost her job as a maid in India's northern city of Dehradun. Her husband no longer can get part-time construction work. Her family has survived on free and subsidized rice, spices and cooking oil from the government -- benefits she attributes directly to Mr. Modi.

"He forced the lockdown on us, but saved our lives," she said.

Still, the string of challenges faced by Mr. Modi and the BJP -- some the result of their own actions, others beyond their control -- came after the prime minister and party cruised to re-election in no small part on a wave of nationalist sentiment stirred up during a confrontation with India's nemesis Pakistan after a terrorist attack killed 40 Indian soldiers in the part of disputed Kashmir that India controls and considers a full-fledged Indian state.

Mr. Modi ordered a bombing in early 2019 of what India said were terrorist outposts inside Pakistan, and an Indian pilot was shot down by Pakistani aircraft and captured briefly before being released to a theatrical hero's welcome in India.

While some analysts questioned India's military prowess in the clash, Mr. Modi and the BJP emerged with a significant boost to his popularity and a sweep of the subsequent election.

Some of Mr. Modi's supporters have tried to suggest his decision to block Chinese apps is a similarly bold move, calling it a "digital strike" on China.

The showdown with China is a stickier challenge, since China is a major Indian trade partner and has a far greater array of ways to counter India if it wanted, from cyberattacks to seeking to undermine its standing in international organizations, according to analysts. More than half of India's overall trade deficit is with China, including imports of critical technology.

Mr. Modi "knows that India can't afford a military confrontation with China," said Tanvi Kulkarni, a visiting fellow at the Institute of Peace and Conflict Studies based in New Delhi.

Mr. Modi has been careful to keep a distance from angry anti-Chinese sentiments -- some of which have boiled over into informal boycotts of Chinese goods that have angered Chinese leadership -- and convened a meeting of all political parties, including the main opposition Congress Party, to discuss ways of handling the crisis.

The showdown with China has been particularly challenging for Mr. Modi's strongman image. His tone has been decidedly measured and cautious compared with that during India's many run-ins with Pakistan since he took office.

After the prime minister declared in the days after the clash that there had been no incursions across India's border, there was an outcry of disbelief from critics. Mr. Modi's office had to issue a clarification for damage control.

"China killed our soldiers. China took our land," opposition leader Rahul Gandhi from the Congress party said on Twitter last month.

The Indian government has claimed, without presenting evidence, that as many as 40 Chinese soldiers also died in the clash. China hasn't acknowledged any deaths on its side.

The claims of Chinese casualties, experts say, could be aimed at propping up Mr. Modi's strongman image while giving him more flexibility to negotiate further face-saving resolutions with China. That was how similar tensions were defused in border face-off with the Chinese in 2017.

--Rajesh Roy contributed to this article.