Edinburgh posted only their fifth win of the Guinness PRO12 campaign when they snatched a 24-20 stoppage-time victory after a spectacular late fightback.
The hosts were first to make an impression on the scoreboard with a Jason Tovey penalty, but they trailed 20-3 with 11 minutes to play before late tries by Blair Kinghorn, Damien Hoyland and a last-gasp touchdown by skipper Grant Gilchrist secured the win.
The Dragons responded to Tovey's early score with a try from Pat Howard, converted by Angus O'Brien, who also landed a penalty for a 10-3 interval lead.
And the Welsh side added a try by Carl Meyer, also converted by O'Brien, that appeared to have clinched the success, only for a late collapse to produce further misery at the end of a week in which the survival of the franchise had been called into doubt -- a situation that should be resolved in the coming days.
Edinburgh opened the scoring after eight minutes when Tovey banged over a penalty.
The hosts continued to enjoy the greater share of the possession and they looked the more likely to score. Hamish Watson posed a constant threat and George Turner, making his first start for the club, also looked lively.
The home side almost added to their tally in 16 minutes but Vilame Mata was forced into touch just short of the whitewash. With more than half an hour on the clock, Dragons mounted their first attack of note, profiting from an Edinburgh error after Hoyland and Tovey collided as they chased the latter's kick ahead.
A slick breakout carried play into the home 22 and the recycled ball was shipped along the line to Sam Beard -- playing against his former side -- who sent Howard in at the left-hand corner.
O'Brien banged over the conversion then added three more points with a long-range penalty as the first half staggered to an error-strewn conclusion.
The Dragons had clearly taken confidence from their first-half effort and dominated the opening 10 minutes of the second period. A series of phases of play edged them closer to the line and the recycled ball was worked left where O'Brien fed Baird and he freed Meyer for his side's second try.
O'Brien again added the extras. Hoyland roused the home supporters in 64 minutes with a mazy run that foundered when he stumbled. However, a minute later the hosts pieced together their best move of the match when the ball was spun along the line to Kinghorn, who raced round behind the posts.
The referee ruled out the score for foul play early in the move by Allan Dell, and yellow-carded the prop. The visitors quickly capitalised on that piece of good fortune and extended their lead to more than two scores when O'Brien booted his second penalty of the evening.
But, as has become their habit, the hosts raised their game in the dying minutes. The Dragons had Rynard Landman yellow-carded with eight minutes left to play and Edinburgh scored almost immediately with a rare flowing move that ended with Kinghorn stretching over the line and Tovey converting.
And the home side seized a lifeline with two minutes to play when a neat reverse pass by Tovey sent Hoyland over. Tovey's conversion sparked a desperate finale and, with the clock ticking past 80 minutes, Edinburgh set about snatching the victory.
And they did so with the final play of the game which saw Gilchrist crash over for the winning score, with Tovey adding gloss when he slotted the conversion.