It was a shock result given that in the last eight years, France have won two Games golds, three world titles and two European crowns.
Denmark's previous Olympics best was a fourth place in 1984.
"I'm super proud of everybody in this group, everyone has worked from the first minute that we showed up this summer," said Denmark's Mikkel Hansen.
"Before I entered these Olympics my dad still had the record in the family. He came in the fourth place in 1984, so I'm happy to show him the medal," Hansen continued. "I've broken the record in the family too, so it's going to be good to see him again."
French key player Nikola Karabatic admitted that the Danes had been the stronger on the day.
"Of course we are very disappointed but we are happy that both the female and male French teams were in the final," said Karabatic.
Germany won the bronze medal earlier Sunday with a 31-25 win over Poland.
With the handball victory, Denmark claimed 15 medals at the 2016 Rio Games.
Even before the weekend's action got underway, the head of the Danish delegation said that this year's medal haul amounted to "the best Olympics we've ever had".
"This is a fantastic experience here [in Rio] and it must also be for the Danes home in Denmark,” Morten Rodtwitt told TV2 Sport.