The 82-year-old triple-vaccinated queen, who already had Covid in February, tested positive on Tuesday evening, the palace said in a statement, a day after the funeral.
“The Queen’s activities this week have therefore been cancelled,” it said, without giving details of her condition.
Margrethe came to the throne at the age of 31 in January 1972 on the death of her father, Frederik IX, becoming the first woman to hold the position of reigning queen in Denmark.
With the death of Queen Elizabeth II, she is now the longest reigning monarch in Europe.
Only the Sultan of Brunei exceeds her by four years.
While fewer than half of Danes were in favour of the monarchy at the time of her accession, the royal family is one of the most popular in the world, enjoying the support of more than 80 percent of the population.
Widowed in 2018, she has repeatedly insisted she will never step down from her duties.
“I will stay on the throne until I drop,” she has said.
Her eldest of two sons, 54-year-old Crown Prince Frederik, is due to succeed her when the time comes.