Media playback is not supported on this device
Ulster twice opened a seven-point lead through tries by wing Craig Gilroy and full-back Jared Payne.
In a week when the Welsh Rugby Union announced they intend to take over the region, Dragons hit back with scores by Rynard Landman and Ollie Griffiths.
Paddy Jackson's kick edged Ulster ahead before Rodney Ah You was shown a red card and Andrew claimed the key try.
Ah You was dismissed after he was adjudged to have made an illegal shoulder charge on Dragons full-back Carl Meyer.
The win means Ulster stay fourth in the Pro12 table, but their failure to gain a bonus point means fifth-placed Scarlets have reduced their cushion to three points with four matches remaining.
Playing for the last time this season at Rodney Parade, Dragons were dominated in the early stages and were seven points down within 10 minutes thanks to Ruan Pienaar's vision and Gilroy's footwork.
The South African scrum half's kick into space bounced horribly for the defenders and Gilroy dribbled the ball into space and touched down near the posts.
The Welsh region dominated possession for the rest of the half, at one stage going through 32-phases, but never really looking likely to score a try.
O'Brien's penalty was cancelled out by Pienaar with Carl Meyer' long-range penalty off target to leave Ulster with a seven-point half-time lead.
A debatable yellow card for Gilroy gave the Dragons a bridgehead which Landman turned into points with a rumbling lineout drive. O'Brien's conversion levelled the scores.
But before the Ulster wing had returned to the field of play full-back Payne cut a clever line to cross for his side's second try.
Dragons, in 10th-place in the table, again hit back with flanker Griffiths charging down a clearance and being given the benefit of considerable double and awarded the try after several TV replays.
Jackson's penalty with eight minutes remaining edged Ulster back ahead before Ah You' careless challenge reduced his team to 14-men with six minutes remaining.
Ulster rallied and kicked for the corner with Andrew claiming the crucial try from the driving lineout.
Media playback is not supported on this device
Dragons: Carl Meyer; Adam Hughes, Tyler Morgan, Sam Beard, Tom Prydie; Angus O'Brien, Charlie Davies; Sam Hobbs, Rhys Buckley, Brok Harris, Nick Crosswell, Rynard Landman, Ollie Griffiths, Nic Cudd, Lewis Evans (capt).
Replacements: Darran Harris, Phil Price, Lloyd Fairbrother, Matthew Screech, Harrison Keddie, Sarel Pretorious, Dorian Jones, Adam Warren.
Ulster: Jared Payne; Craig Gilroy, Luke Marshall, Darren Cave, Charles Piutau, Stuart Olding, Ruan Pienaar; Andrew Warwick, Rob Herring (capt), Wiehahn Herbst, Kieran Treadwell, Alan O'Connor, Iain Henderson, Chris Henry, Sean Reidy.
Replacements: John Andrew, Callum Black, Rodney Ah You, Robbie Diack, Clive Ross, Paul Marshall, Paddy Jackson, Jacob Stockdale.
Referee: Mike Adamson (Scotland)
Assistant referees: Sam Grove-White (Scotland), Dan Jones (Wales)
TMO: Jim Yuille (Scotland)
John Andrew's late try secured 14-man Ulster a crucial win against Newport Gwent Dragons.