Prince Henrik, the French-born husband of Danish Queen Margrethe who publicly vented his frustration at not being the social equal of his wife or their son in line to become Denmark's king, has died aged 83.
The father-in-law of Crown Princess Mary was diagnosed with dementia last year and was hospitalised late last month with a lung infection.
Henrik had been transferred on Tuesday from a Copenhagen hospital to Fredensborg Castle, where he had wanted to spend "his final time".
"His Royal Highness Prince Henrik died peacefully in his sleep ...," the royal palace said in a statement on Wednesday.
"Her Majesty the Queen and the two sons were at his side."
"The royal family has lost an anchor," Prime Minister Lars Loekke Rasmussen said in a statement, who said Henrik "kept his good spirits 'til the end".
Flags were at half-mast across Copenhagen and national radio channels changed their programs to broadcast more austere music interrupted by anecdotes about Henrik's life.
The royals will undergo a month of mourning during which they will wear dark clothing and not take part in social events.
Danes can bid farewell to the prince on Saturday at the chapel of the downtown Christiansborg Palace, where his casket will be on display.
A funeral will be held there on February 20.
The palace said it would respect Henrik's wish to be cremated, with half his ashes spread over Danish seas and the other half buried in a private garden at the Fredensborg Palace.
The Danish royal family has no political authority but is one of the world's oldest kingdoms and prides itself on stability.
Henrik, however, caused a scandal last August by announcing that when he died he did not want to be buried next to Margrethe in the cathedral where the remains of Danish royals have gone for centuries.
Born to a count and countess on June 11, 1934, in southwestern France, Henri Marie Jean Andre de Laborde de Monpezat married Denmark's future queen in 1967.
Henri became Henrik and converted to Denmark's state Lutheran Church. However, he found it difficult to fit in with the country's egalitarian lifestyle.
He was titled prince consort and he was not in the line of succession, with his oldest son Frederik - husband of Tasmanian-born Mary - being the heir.
Shortly after the royal marriage, the media criticised Henrik because he had aired his views that spanking was good for children.
In the mid-1980s, Henrik said publicly he wanted a pay cheque instead of relying on the queen.
The law was changed to give him about 10 per cent of the allocation parliament makes to royals each year.
In 2002, Henrik again stunned Danes by saying he felt he had been pushed aside in his own home, not only by his wife but also by his son.
"For many years I have been number two," Henrik told Danish tabloid B.T.
"I have been satisfied with that role but after so many years in Denmark I don't suddenly want to become number three and become some kind of wearisome attachment."
After retiring from official duties in 2016, he spent much of his time at his vineyard in Chateau de Cayx, France, although he remained married to the Queen and was officially still living with her.
The prince was also a passionate artist, producing several poems, sculptures and cooking books.
In January, he was admitted to a hospital with a lung infection and later was said to have a benign tumour.
The palace said on Friday his condition had "seriously worsened" and Crown Prince Frederik was rushing home from the Winter Olympics in South Korea.
Henrik is survived by his wife, sons Crown Prince Frederik and Prince Joachim, and eight grandchildren.
Australian Associated Press