The Danish rider was part of a breakaway sprint just 300 metres from the finish line, beating out both Pavel Sivakov (Team Ineos) and Jai Hindley (Team Sunweb) in the Koscielisko stage.
Jonas Vingegaard wins Stage 6 to take race lead
The trio had already been part of a group that had thinned out some of the peloton on the ascent to Gubaowka which took place 2.5km from the end of the race.
It had seemed that Hindley was in control as he took pole position in the breakaway into the urban roads of the city, and he was favourite with halff a kilometre to go. However Vingegaard unleashed a suprise sprint of his own and relegated the other two rivals to the final two podium places.
The win for the 22-year-old rider took the leader's jersey from Bora-Hansgrohe's Pascal Ackermann, who had led from the fist stage, and he now has a four second advantage over Sivakov.