Shane Williams scored a dramatic late try and conversion on what was billed as his farewell game for the Ospreys before retirement.
But the 34-year-old's try may lead to the Ospreys hosting a home game in the Pro12 play-offs.
The Dragons were in the game until the 78th minute when the Ospreys were awarded a second penalty try.
And Williams prised open the Dragons's stubborn defence before converting the injury-time score.
Williams' effort echoed his final Wales appearance, when he went over after 80 minutes had passed in a 24-18 defeat by Australia in December.
But on this occasion, Williams' try brought the reward of the bonus point that could prove so crucial as they head into the league's final round on Saturday, 5 May when they travel to Italian strugglers Aironi.
The Dragons' preparations were hit by a sickness bug among the squad in the build-up and skipper Luke Charteris' late withdrawal because of a shoulder injury.
But the visitors showed little sign of the troubles that preceded the kick-off.
The Dragons lived up to the Ospreys' expectations by putting up a better show than Cardiff Blues mustered in the hosts' previous outing.
Despite dominating the opening 10 minutes and creating clean line breaks for wing Hanno Dirksen, flanker Ryan Jones, lock Ian Evans, the Ospreys fell behind to Robling's first penalty.
Amid the Ospreys early lack of a killer instinct, the Dragons could point to Toby Faletau's try-saving tackle on Hibbard.
Biggar and Robling exchanged penalties before Ryan Jones stole over from a close-range ruck in the 20th minute for the first try and the Ospreys' fly-half converted.
Dragons wing Aled Brew brought Dirksen down by launching his body at the his opponent's legs to again deny the hosts.
But the Ospreys' pressure at series of close-range scrums told as first Nathan Buck was sin-binned before referee Nigel Owens' patience wore so thin he awarded a penalty try.
Biggar converted, but the hosts were unable to profit from Buck's absence either side of the break and it fell to Robling to again frustrate the Ospreys with two more penalties that left the outcome finely balanced.
Home fly-half Biggar was next to the sin-bin after he was judged to have illegally halted Brew's attempt at a tap penalty.
And before any more scores, replacement Dragons prop Dan Way was also yellow-carded.
In Way's absence, the Ospreys claimed another penalty try from a scrum.
Then Williams broke free to the delight of the biggest rugby crowd at the Liberty Stadium this season, 14,478.
Ospreys: Ross Jones, Hanno Dirksen, Tom Isaacs, Andrew Bishop, Shane Williams, Dan Biggar, Rhys Webb; Ryan Bevington, Richard Hibbard, Adam Jones, Alun Wyn Jones (Capt), Ian Evans, Ryan Jones, Joe Bearman, Justin Tipuric.
Replacements: Ashley Beck for Isaacs (60), Kahn Fotuali'i for Webb (41), Paul James for Bevington (63), Tom Smith for Evans (60).
Not Used: Baldwin, Rees, King, M Morgan.
Sin Bin: Biggar (50).
Dragons: Hallam Amos; Tonderai Chavhanga, Adam Hughes, Ashley Smith (capt), Aled Brew; Lewis Robling, Wayne Evans; Nathan Williams, Steve Jones, Nathan Buck, Robert Sidoli, Jevon Groves, Danny Lydiate, Toby Faletau, Lewis Evans.
Replacements: Martyn Thomas for Chavhanga (48), Joe Bedford for W Evans (63), Phil Price for N Williams (63), Sam Parry for S Jones (56), Dan Way for N Buck (56).
Not Used: Coombs, Brown, Leach.
Sin Bin: Buck (34), Way (69).
Referee: Nigel Owens (WRU)
Assistant referees: Neil Hennessy, Wayne Davies (WRU)
Citing commissioner: Gwyn Bowden (WRU)
TMO: Gareth Simmonds (WRU)