Indians light candles in Mumbai on Wednesday in remembrance of soldiers who were killed in an attack on an Indian army camp in Uri, (Divyakant Solanki/European Pressphoto Agency)

Dhruva Jaishankar is a fellow for foreign policy at Brookings Institution India in New Delhi.

NEW DELHI — The killing of 18 Indian soldiers on Sunday, which New Delhi blames on Pakistan-based militants, is just the latest incident to drive a wedge between the two countries. Indian Prime Minister Narendra Modi has spent his first two years in office engaging his Pakistani counterpart, Nawaz Sharif. In an unprecedented move, Sharif was invited to Modi’s inauguration, and Modi even made an unplanned visit to Sharif’s home near Lahore last December. But the prospects of more normal bilateral relations between the two nuclear-armed countries soured this summer, when popular protests in Indian-administered Kashmir led to renewed attempts by Pakistan to internationalize the dispute over that territory. India countered by drawing attention to human rights abuses in Pakistan’s restive Balochistan province. After the latest assault near the Kashmiri town of Uri, the deadliest attack on the Indian Army since 2002, relations between India and Pakistan can be expected to remain frosty.

But as India and the world continue to grapple with Pakistan’s support for Islamist militant groups, another story is unfolding in the region: India is rediscovering the rest of its neighborhood. In the past few weeks, Myanmar’s President Htin Kyaw, Afghan President Ashraf Ghani and Nepali Prime Minister Pushpa Kamal Dahal have all visited New Delhi. The prime ministers of Sri Lanka and Bangladesh are also scheduled to arrive soon. This is part of a conscious bid by India to give priority to its smaller neighbors, lend support when needed, increase connectivity and gradually build a sense of regionalism. This policy has come to be known as “Neighborhood First.”

India’s aggressive engagement with its neighbors over the past two years has been motivated by two interrelated concerns. One is the rising tide of nationalism, which often manifests itself as anti-Indianism in many of these countries. In Nepal, Bangladesh and Sri Lanka, certain political parties or blocs have tried to exploit anti-Indian sentiments and could, once again, rise to positions of power. The governments in all three countries are, at present, relatively well-disposed toward New Delhi, but there is no certainty that such a situation will last.

Additionally, every country in India’s periphery (with the exception of landlocked Bhutan) is seeing the growing economic and political influence of China, now unquestionably South Asia’s second power. Pakistan and Bangladesh are the two largest recipients of Chinese arms. China is also a major investor and trade partner with Sri Lanka and the Maldives, and is playing a greater role in national politics, as in Nepal. For India’s smaller neighbors, playing the China card is a tempting way to counter perceived Indian regional hegemony.

South Asia is often said to be the least integrated region in the world. But while a deep divide persists between Pakistan and India, and the volume of regional trade remains uninspiring, several factors that connect the subcontinent are often overlooked. For example, Nepal enjoys open borders with India, which also accounts for 64 percent of its trade. In 2014, more than $4 billion in remittances flowed from India to Bangladesh. Meanwhile, Sri Lanka has emerged as a major transit hub for commerce with India, and India is home to some 60,000 Sri Lankan refugees. Afghanistan is the largest recipient of Indian foreign assistance. Last week, New Delhi pledged to provide $1 billion in economic aid to Kabul. Despite adverse conditions, India has concluded major road, electricity and dam projects in Afghanistan and helped build the country’s parliament building.

India’s neighborhood engagement has not been restricted to trade, aid and migration. New Delhi has also been taking a stronger position on its neighbors’ long-term political trajectories. This has involved support for a democratic transition of power and resettlement of refugees after the end of the Sri Lankan civil war. With Bangladesh, India has solidly backed the secularism of Prime Minister Sheikh Hasina’s Awami League against violent Islamist forces. New Delhi has also welcomed democratic transitions in Afghanistan and Myanmar. More controversially, India last year pressured Nepal to amend its new constitution, which it believed discriminated against minorities. Democracy, pluralism and secularism are all ideals ingrained in the Indian constitution, and there is a growing realization of the need to advance these values in India’s own periphery.

Of course, India has often had to compromise, taking into account tactical considerations and short-term interests. While welcoming Myanmar’s democratic transition, India has been noticeably silent on the fate of the Rohingya, an ethnic group that the Myanmar government discriminates against and refuses to acknowledge as citizens. In Bangladesh, India stood behind Hasina despite flawed elections in 2014 that were boycotted by the main opposition party. And in the Maldives, India has had to do deals with the government of Yameen Abdul Gayoom, even as India pressures it to democratize.

With the rise of nationalism and the rise of China, the high level of diplomatic engagement underway between India and its neighbors is likely to represent the new normal. For the foreseeable future, India will be playing aggressive defense in its own back yard.