Bangladesh and India have signed a historic agreement to simplify their border by exchanging more than 150 enclaves of land.
India's Prime Minister Narendra Modi ratified the deal with his counterpart Sheikh Hasina in Dhaka.
Thousands of Bangladeshis inhabit more than 50 enclaves in India, while Indians live in around 100 areas within Bangladesh.
The countries will now swap territories and residents can choose where to live.
"We have resolved a question that has lingered since independence. Our two nations now have a settled boundary," Mr Modi said at a press conference.
"We are not just neighbours, but nations bound by the threads of history, religion, culture, language and kinship - as well as a passion for cricket."
Bangladesh Foreign Minister Abul Hassan Mahmood Ali described the agreement as "a historic milestone in the relationship between the two neighbouring countries".
The agreement is significant because it is the first step by Bangladesh to allow road transit to India, a long-running Indian demand which it hopes will eventually enable it to have better access to its north-eastern states.
Analysis: Sanjoy Majumder, BBC News, Delhi
Foreign Ministry officials in India have described Prime Minister Narendra Modi's visit to Bangladesh as one of his most significant since taking office a year ago. That's because of the historic Land Border Agreement that is to be signed between the two countries.
More than 50,000 people currently live in tiny enclaves - citizens of one country but located in the other. Under the agreement, both sides will swap the enclaves enabling their citizens to finally reside in their own countries.
It's a dispute that dates back to colonial times and has been a contentious issue since. Relations between Bangladesh and India have improved under the government of Sheikh Hasina, and Mr Modi has also made it a priority for his foreign policy.
The border issues go back to colonial times Both leaders have welcomed the enclave agreement The enclaves along the 4,000km border are a legacy of colonial times - the British departed India before the border was properly demarcated - and have been a contentious issue between the two nations for decades.
Inhabitants are in effect stateless and lack access to public services.
The terms of the long-awaited treaty- The two countries will swap up to 200 tiny enclaves, a move that should improve the lives of many inhabitants who live in squalid conditions
- Each country will now begin to administer enclaves on its territory and enclave citizens will be able to choose where they want to live and which nationality they would prefer
- A deal was originally agreed in 1974 by Indira Gandhi of India and Sheikh Mujibur Rahman of Bangladesh. But following the assassination of Sheikh Mujib in 1975, it was not implemented
In some enclaves it is possible to find houses that straddle both countries.
Mr Ali said the two countries would also sign a number of deals to boost trade and security along the border, fight human trafficking and share water resources.