The dispute, in one of the most remote corners of the world, was brought to an end with an exchange of alcohol.
Canada and Denmark finally ended their decades-long "war" on Tuesday, fought over flags, whisky and schnapps on an uninhabited island in the high Arctic.
The two countries formally signed an agreement to share Hans Island off northwest Greenland, creating the first land border between Canada and Europe, at a ceremony in Ottawa attended by the Canadian foreign minister and her Danish counterpart.
The dispute, which has been at a benign impasse for 49 years, will see the kidney-shaped island split in two and the agreement between Ottawa and Copenhagen held up as a model for resolving territorial disputes around the world.
"The Arctic serves as a beacon of international cooperation, where the rule of law prevails," said Canadian Foreign Minister Mélanie Joly.
"At a time when global security is threatened, it has never been more important for democracies like Canada and Denmark to work together, alongside indigenous peoples, to resolve our differences in accordance with international law," she added.
At a press conference with Danish Foreign Minister Jeppe Kofod, she stressed that the conflict - "which many have dubbed the 'whisky war'" - was "the friendliest of all wars".
Kofod said that the resolution of the conflict came at a time when "the international order based on law is under pressure", and democratic values are "under attack", referring to the war in Ukraine.
"In contrast, we have demonstrated how long-standing disputes can be resolved peacefully by following the rules," he said, adding that he hoped to "inspire other countries to follow the same path".
Hans Island, which covers 1.3 square kilometres, is located between Ellesmere Island in northern Canada and Greenland, a Danish territory. The dispute dates back to 1973 when a maritime boundary was drawn between the two countries.
Canadian whisky vs Danish schnapps
The Danes and Canadians have taken turns flying to the island to claim the territory, leading to diplomatic protests, online campaigns, and even calls for Canada to boycott Danish pastries.
During these visits, each side would plant a flag and leave behind a bottle of whisky or schnapps for the other side.
As they exchanged bottles on Tuesday, Mélanie Joly and Jeppe Kofod joked that Canada could join the European Union now that the two entities share a land border. Although Denmark is a member of the EU, Greenland is not, following a referendum in the 1980s.
Snow-covered Hans Island is uninhabitable, but the effects of climate change are bringing more and more shipping traffic to the Arctic and opening it up to more exploitation of its resources, especially fisheries.
According to Arctic expert Michael Byers, however, the island is "so extraordinarily remote that it is not economically viable to consider any serious activity there".
Postponing any resolution of this unusual dispute indefinitely has long been a good opportunity for political posturing on both sides, especially in the run-up to elections.
"It was an entirely risk-free sovereignty dispute between two Nato allies over a tiny, unimportant island," Michael Byers said.
Denmark also feared that losing the battle over Hans Island would undermine its relationship with Greenland, while Canada was concerned that a defeat would weaken its negotiating position with the US in a much bigger dispute in the oil-rich Beaufort Sea in northwestern Canada.
Canadian Prime Minister Justin Trudeau "has not made Arctic sovereignty part of his political identity", according to Michael Byers, which has helped to "lower the temperature", at least on the Canadian side.
"But more importantly, Russia invaded Ukraine, and that created the right moment to tell the world that responsible countries were agreeing on their territorial disputes in a peaceful way," he added.