After a final horse-drawn carriage procession through the streets of Copenhagen, the hugely popular 83-year-old queen signed a declaration of abdication at Christiansborg Palace, ending her 52-year reign and automatically making her son monarch.
She then left the Council of State, also attended by the government, the new king, his wife and their 18-year-old eldest son, the new Crown Prince Christian.
Margrethe left the room with tears in her eyes, saying: "God bless the king."
In front of a sea of Danes waving red-and-white flags, Prime Minister Mette Frederiksen then proclaimed 55-year-old Frederik the new king on the balcony of Christiansborg Palace, the seat of parliament and government.
Warped up against the cold, a visibly moved Frederik, clad in his gala admiral's uniform with gold epaulettes, blinked back tears and smiled as he waved to the crowd, estimated at more than 100,000 people by media outlets.
Like his mother, Frederik is hugely popular, enjoying the support of more than 80 percent of Danes.
"My mother succeeded like few others in becoming one with her country," he told the crowd.
"My hope is to become a unifying king for the future... It's a responsibility I assume with respect, pride and a lot of happiness," he said, repeatedly placing his hand on his heart as the crowd cheered.
"I think he's going to be a great king. I'm looking forward to seeing how he's going to do it and see him show more of himself," Rene Jensen, a Copenhagen resident fitted out for the day in a red velvet robe and crown, said.
Frederik was then joined on the balcony by his Australian-born wife Mary, wearing a white dress with her dark hair swept back in a bun, and their four teenage children.
Mary is the first commoner to become queen in Denmark.
The crowd erupted in loud cheers as the new king and queen kissed on the balcony.
It is only the second time a Danish sovereign has stepped down -- the last one was Erik III, almost nine centuries ago in 1146.