A territorial dispute between Denmark and Canada over a barren and uninhabited rock in the Arctic that has led to decades of friendly friction has come to an end, with the two countries agreeing to divide the tiny island between them.

Under the agreement, a border will be drawn across the half-square-mile Hans Island, in the waterway between the north-western coast of the semi-autonomous Danish territory of Greenland and Canada's Ellesmere Island.

The rock has no mineral reserves.

"It sends a clear signal that it is possible to resolve border disputes... in a pragmatic and peaceful way, where the all parties become winners," said Danish foreign minister Jeppe Kofod.

He said it was "an important signal now that there is much war and unrest in the world".

Canada and Denmark agreed in 1973 to create a border through the Nares Strait, halfway between Greenland and Canada, but they were unable to agree which country would have sovereignty over Hans Island, about 684 miles south of the North Pole.

In the end, they decided to work out the question of ownership later.

In the following years, the territorial dispute - nicknamed the "whisky war" by media - raised its head multiple times.

In 1984, Denmark's minister of Greenland affairs raised a Danish flag on the island, buried a bottle of Danish schnapps at the base of the flagpole and left a note saying: "Welcome to the Danish island."

Canadians then planted their own flag and left a bottle of Canadian brandy.

Since then, the countries have in turns hoisted their flags and left bottles of various spirits in tit-for-tat moves.

In 2002, Nana Flensburg was part of a Danish military crew that stood on the cliff to perform a flag-raising ceremony.

The Politiken newspaper on Tuesday quoted her as saying in her diary that "among the stones in the cairns were lots of bottles, glasses, etc, with documents that informed about previous visits to the island."

The agreement comes into force after the two countries' internal procedures have been completed. In Denmark, the parliament must first give its consent to the agreement.