Bangladesh and India have sealed a deal to swap border territories, more than 40 years after it was negotiated.

The prime ministers of both countries watched as bureaucrats signed the pact in Dhaka, Bangladesh’s capital. The deal, reached in 1974 but only recently ratified by India’s parliament, will be seen as a major achievement for Narendra Modi, the Indian prime minister, who won a landslide election last year to take power. “[The deal] will make our borders more secure and people’s lives more stable,” the 64-year-old leader said.

Modi has had difficulty delivering achievements domestically, but has been active on the international scene and compared the agreement with the dismantling of the Berlin Wall.

“[Foreign policy] is one area where there has been unexpected and major progress,” said C Raja Mohan, an Indian foreign affairs analyst. “This will open the door for significant co-operations and economic engagement.”

Just an hour after Modi’s arrival in Dhaka, top Indian conglomerates signed outline agreements with Bangladesh’s state-run electricity agency to invest some $5bn in the country’s rickety power sector.

Indian officials said yesterday’s agreement sent an important signal that the border disputes that plague India’s relations with other regional powers could be solved, but added that disagreements with Bangladesh were easier to resolve than those with rival Asian giant China, or with Pakistan, with which India has fought four wars.

The agreement was also a boost for Sheikh Hasina, the prime minister of Bangladesh. Hasina won a disputed election last year which was boycotted by the opposition and dismissed as lacking credibility by some western governments. She has been criticised since for cracking down on dissent.

Scores of people have been killed in firebomb attacks on vehicles since opposition leaders called a transport blockade at the start of the year in an attempt to oust the current government. Relations between India and its smaller neighbour have significantly improved since Hasina promised her administration would not allow India’s separatist insurgents to use the porous 2,500-mile border to carry out raids. Eighteen soldiers died in an ambush blamed on the separatists last week. The Indian army helped Bangladesh gain independence from Pakistan in a bloody nine-month war in 1971 and relations have usually been warm.

There are hopes now that the border agreement will also boost trade. It will allow tens of thousands of people living in 162 enclaves resulting from ownership arrangements made centuries ago by local princes either side of the border enclaves to choose their nationality after decades of stateless limbo. “This is a way of cleaning up the mess left by partition [of British India in 1947],” said Mohan. India’s parliament only gave its approval last month.

People living in the enclaves will be allowed to choose to live in India or Bangladesh, with the option of being granted citizenship in the newly designated territories, and the enclaves would effectively cease to exist.

Wary of China’s growing interest in India’s backyard, Modi has been keen to play a greater leadership role in South Asia since coming to power.

He is set to meet Khaleda Zia, the main Bangladesh opposition leader. Indian officials have played down the idea of Modi playing a mediation role in the dispute between Hasina and Zia, although he might press on Zia to ensure an end to anti-government attacks.

India held off from criticising Hasina’s re-election in January 2014.