Denmark finished second in Group C by virtue of having a better disciplinary record than Slovenia after dull draw with Serbia.
Neither side produced a performance that reflected their potential, but Denmark were the better team in a forgettable encounter in Munich.
Denmark ended on an identical record to Slovenia, meaning they had to be separated by the amount of yellow cards they received.
While Denmark and Slovenia both go through, Serbia are out – although none of the three teams won a group game.
Jonas Wind had a goal disallowed for Denmark in the first half because the ball had gone out of play before he bundled it over the line from a corner.
The Wolfsburg forward also slipped as he tried to connect with a smart flick-on from Rasmus Hojlund, slicing over the bar from a good position, and was substituted at the break.
Denmark continued to create chances despite a poor display by their standards. Alexander Bah headed wide and Christian Eriksen’s shot had to be parried behind for a corner.
Serbia, who knew they would be eliminated if they did not win because of Slovenia’s stalemate with England in the other Group C match, had just one shot on target that came in second-half stoppage time.
They had a goal ruled out when Luka Jovic’s shot bounced in off Denmark defender Joachim Anderson in the second half. Striker Jovic had been offside in the build-up.
Knowing their place in the last 16 was secure with a draw, a pragmatic Denmark side lacked ruthlessness. Jannik Vestergaard headed a corner delivery at Serbia goalkeeper Predrag Rajkovic, but the Danes rarely tested him in the second half.
As group runners-up, they have set up a tie with tournament hosts Germany in the next round.
“We are representing Danish football and we have to be happy about it,” said Denmark manager Kasper Hjulmand.
“It’s special of course when you play the hosts. It is a fantastic football country with a lot of passion.
“I really love football here in Germany and playing against them with the Danish team – it cannot be better. I can’t wait.”
Denmark ease into last 16 as Serbia struggle
All four teams from Group C had a chance of reaching the knockout stages before Tuesday’s matches kicked off, but Serbia never looked like winning this one.
Cheered on from the stands by 24-time Grand Slam tennis champion Novak Djokovic, Serbia could not rise to the occasion and went out of the competition with a whimper.
A few opportunities came late on as Aleksandar Mitrovic curled a shot wide, Dusan Vlahovic’s header landed on the roof of the net and Sergej Milinkovic-Savic struck their first shot on target – but Denmark were not fazed.
It had been a disappointing performance from Serbia as their supporters jeered at half-time and frustrations grew in the second half when referee Francois Letexier ruled out their goal for offside.
Plastic cups were thrown on to the pitch and play had to be stopped twice as stewards and Denmark goalkeeper Kasper Schmeichel cleared them, followed by an announcement pleading for fans to stop hurling objects.
Jovic and Dusan Tadic had been brought on at half-time as Serbia looked for inspiration, but Denmark continued to control possession while not taking many risks.