Of all the visits to 25 foreign countries that Narendra Modi has made since he became India’s prime minister 14 months ago, a recent trip to neighbouring Bangladesh yielded perhaps the most concrete outcome.

On a relatively brief weekend visit in June, Modi signed an agreement with Sheikh Hasina, Bangladesh’s prime minister, for the two countries to swap 162 small parcels of land known as enclaves that were left behind in each other’s territories when boundaries were drawn in 1947.

The Indian government has announced today that the exchanges are being implemented from midnight tonight.

That may sound simple and unremarkable, but in the tortuous world of South Asian politics and diplomacy, it is a rare breakthrough. Among Modi’s visits, it has been matched only by the chord he struck with President Barack Obama in the US last October, having been denied a US entry visa for nine years after the 2002 Godhra riots in his state of Gujarat.

The land deal, one of about 20 agreements signed during Modi’s visit, ended more than four decades of bickering with Bangladesh. It is a rare example of India getting its regional diplomacy right, and seeing a deal through to a successful conclusion.

Tariq Karim, a former top diplomat and, till recently, Bangladesh’s high commissioner in Delhi, praises Modi’s role for achieving what he describes as the “first solution for a post-colonial land dispute in South Asia since independence”.

India hopes it becomes an example of what it can achieve with its other neighbours, though such efforts are bedevilled by fractious relations with Pakistan, and by China’s ambitions to eclipse India and become the undisputed regional power. China has been increasing its influence on all India’s neighbours for many years, and has recently even emerged as an internationally accepted key player in Afghanistan’s embryonic peace talks, leaving India without a role.

It is rare for real progress to be made. Modi hoped that talks that he had with Nawaz Sharif, Pakistan’s prime minister on the sidelines of a multi-lateral conference in Russia early in July would also yield positive results. The pleasantries, and the way that top officials jointly delivered their statements after the meeting, looked remarkably hopeful, but this was quickly followed by negative noises from Islamabad. Then on July 27 there was a 12-hour terrorist attack and gun battle at an Indian police station at Gurdaspur in Punjab near the border that killed seven people including four (inevitably) ill-equipped and under-prepared Indian police guards.

India and Bangladesh have a 4,100km (2,500-mile) border drawn erratically in heavily populated areas that left the enclaves invisible on most maps and on the ground. Some 50,000 inhabitants have effectively been stateless in 111 Indian enclaves located in Bangladesh and 55 Bangladeshi enclaves in India.

The Economist reported that there was even “the world’s only ‘counter-counter-enclave’ – a patch of India surrounded by Bangladeshi territory, inside an Indian enclave within Bangladesh”. One theory about the history is that the enclaves “resulted from a series of chess games played between two maharajas centuries ago” while another suggests that they were “borne of 18th-century treaties signed between local rulers and the Mughal empire, before the emergence of the British raj”.

The next challenge for the two countries is to complete a long-delayed agreement on sharing the waters from the Teesta River, one of 54 rivers flowing between the two countries. The Teesta rises in the Indian state of Sikkim and flows through West Bengal to Bangladesh, which makes sharing the waters a sensitive issue in both countries.

A bilateral deal was also almost done by Manmohan Singh when he made a prime ministerial visit to Dhaka in 2011, but he failed because Mamata Banerjee, the unpredictable irascible chief minister of West Bengal, refused to go along on the visit and approve the deal.

That may have been partly pique that she had not been properly consulted in advance, but she was also worried about political repercussions in the north of her state that could lose some water.

Modi’s breakthrough on the enclaves was partly the result of liaison with Banerjee that led to financial grants for her state and to her being in Dhaka at the same time as his visit. Modi was also able to persuade the Bangladeshis that Delhi would deliver on its promises, which meant overcoming historic distrust of India’s often over-bearing diplomacy.

Perhaps the most startling feature of the weekend visit was the welcome given to Modi by Bangladesh’s political opposition, especially the Bangladesh Nationalist Party (BNP) led by Khaleda Zia, whose decades long rivalry with Hasina has held back the country’s economic and political development. Zia boycotted a general election in January last year and has has staged street protests to ry to force fresh elections.

Zia’s welcome indicates that the new co-operation with India could survive a change of government, though the BNP might create problems on a Teesta agreement. Bangladesh’s politics are volatile and unpredictable – the latest instability comes from a leading BNP politician being sentenced to death for alleged war crimes during the country’s 1971 war of independence from Pakistan.

Commentators in India have heralded the land deal as a springboard for Modi to transform relations with other neighbours. That however won’t be easy, though Subrahmanyam Jaishankar, India’s foreign secretary, has talked about the relationship with Nepal being transformed by the instant help that India gave after a recent earthquake and by co-operation on hydro power generation that Nepal had resisted for many years.

Wherever India goes however, China will be there as well, and in force. Sri Lanka had a pro China government till a presidential election at the beginning of this year brought in a leader who favoured Delhi, but that position might be reversed in a general election on August 17. Meanwhile, it looks as if China’s grip on the nearby Maldives islands, previously an India ally, is complete.

India cannot stop this trend, so the challenge is to make what progress it can, as Modi has done with the Bangladesh enclaves.