Omar Daley gave the Bantams the lead early on only for Jemal Johnson to hit back for the hosts just before the break.
But nine minutes from time Lee took centre stage to cause a minor shock against League One opponents.
The visitors had stunned Roberto Di Matteo’s men by going ahead after just 90 seconds when Daley skipped past Shaun Cummings to race clear and plant the ball in the bottom corner.
The Bantams looked comfortable until a couple of minutes before half-time when they were surprised by a low Johnson thunderbolt which beat Rhys Evans.
But despite some Dons’ pressure after the break, Lee left them reeling with a superb low free-kick from 30 yards to send Bradford through.