The Lions needed a late Steve Morison header to cancel out John Akinde’s early penalty to stay in the tie after 90 minutes.
But Akinde teed-up Yiadom for a 102nd-minute winner as Millwall, three divisions above their visitors last season, suffered a humiliating first-round exit.
The Bees stunned The Den in the 11th minute after Byron Webster’s clumsy challenge tripped Akinde in the area.
Akinde, whose 31 goals propelled Barnet to the Conference title last season, coolly sent debutant Millwall goalkeeper Jordan Archer the wrong way to open his account for this term.
The hosts were thrown a 61st-minute lifeline when Luke Gambin upended Fred Onyedinma in the area but Morison, back in south London for a third spell after leaving Leeds over the summer, lifted his penalty against the crossbar.
However, Morison made amends 15 minutes later with a neat back-header from a Shaun Williams free-kick which deceived former Lions keeper Graham Stack as it looped in at the far post.
Archer made a fine save to keep out Yiadom’s curler and Stack denied Morison a second with neither side able to find a winner before the end of normal time.
But Barnet wrapped up a deserved victory when Akinde out-muscled Webster on the byline and crossed for Yiadom to score with a simple tap-in.