Germany, seeking their seventh European trophy in a row, took the lead through Isabel Kerschowski after only three minutes.
But an equaliser four minutes into the second half from Nadia Nadim gave Denmark new belief, and Theresa Nielsen sealed their win with a header inside the final 10 minutes.
Kerschowski’s early strike, misjudged by keeper Stina Lykke Petersen, had seemed likely to herald a dominant performance by Germany, but they failed to capitalise on a hesitant start by their opponents.
Nadim made them pay by heading home at the far post, before the unmarked Nielsen completed the turnaround.
After fleeing her native Afghanistan, Nadim found a new life in Denmark where it was acceptable for women to play football in public. Now she hopes to pay back her adopted nation as they take on Germany in a bid to recreate the famous Euro 1992 upset.
Like many of the women playing in the European Championships Nadia Nadim was introduced to football by her father, who brought home a ball when she was a little girl. The rest of her story, however, is unique, a tale of tragedy and triumph even Hollywood might balk at.
Denmark is Nadim’s adopted country. One of five sisters she was born and grew up in Afghanistan where her father, Rabani, was a general in the Afghan Army. When she was 10 the Taliban, who controlled the country, summoned her father to a meeting. He never returned. It was six months before her mother, Hamida, discovered he had been taken into the desert and executed.
The family put their savings into escape, being trafficked to Europe via Pakistan and, with forged passports, a flight to Italy. There they were put on a truck expecting to be taken to London, where Hamida had relatives. Several days later the bus stopped, the occupants turfed out. It was not what they expected. They asked a passer-by and found they had been dumped in rural Denmark.