Gianluca Scamacca grabbed his third Euro goal of the campaign to rescue West Ham.
The £30m Italian blasted the Hammers ahead after an early scare and some terrible refereeing against the Danes.
Scamacca fired in a power drive from 20 yard after Maxwell Cornet won the ball and fed his strike partner. He got one in each tie against Viborg.