The 83-year-old queen, who ascended the throne in 1972, made the surprise announcement on live TV during her traditional New Year's Eve speech, which is viewed by many in the country of 5.9 million people.
Referring to a successful back operation she underwent in February, she said, "The surgery naturally gave rise to thinking about the future - whether the time had come to leave the responsibility to the next generation".
"I have decided that now is the right time. On 14 January 2024 – 52 years after I succeeded my beloved father – I will step down as queen of Denmark," she said.
"I leave the throne to my son, Crown Prince Frederik," she said.
The queen became the longest-serving monarch in Europe following the death of Britain's Queen Elizabeth II in September 2022. In July, she became the longest-sitting monarch in Denmark's history.
In Denmark, formal power resides with the elected parliament and its government. The monarch is expected to stay above partisan politics, representing the nation with traditional duties ranging from state visits to national day celebrations.
Born in 1940 to Denmark's former monarch King Frederik IX and Queen Ingrid, Margrethe has throughout her life enjoyed broad support from Danes, who are fond of her tactful and yet creative personality.
She is also known for her love of archaeology and has taken part in several excavations.
She became heir to her father in 1953 at the age of 31, after a constitutional amendment allowed women to inherit the throne.
In 1967, she married French diplomat Henri de Laborde de Monpezat, who served as her royal consort until his death in 2018.
The couple's two sons are Crown Prince Frederik, who will become King Frederik X, and Prince Joachim. Frederik married Mary Elizabeth Donaldson, an Australian, in 2004.
Reuters