Ross County moved up to seventh place in the Scottish Premier League with a hard-fought win over basement side Dundee at Dens Park.
Gary Harkins, back at Dundee after his spell at Kilmarnock, fired over the bar in a rare first-half chance for the home side as County had the upper hand.
Paul Lawson's powerful shot rattled down off the crossbar and was deemed to have crossed Rab Douglas's goal-line.
And deep into injury-time Gary Glen controlled a long kick-out to score.
This was a match Dundee really needed to win yet they got off to a bad start when Lewis Toshney, on loan from Celtic, was sloppy with his back-pass to Douglas in the first minute.
County midfielder Rocco Quinn was quick to pounce but the home keeper managed to race off his line to clear the danger.
That signalled a hectic night for Douglas, who made good first-half stops from County's Mihael Kovacevic and Sam Morrow.
As half-time neared, Harkins shifted the ball between his feet neatly to fire a fierce left-foot effort just over Mark Brown's bar.
In the second half Morrow lobbed wide of the Dundee goal when he seemed certain to score and substitute Steffen Wohlfarth lifted his effort high over the bar when he went one on one with Douglas.
Douglas was busy again a few minutes later, first parrying a ball away to his right and then springing forward to block a Morrow shot.
Dundee had chances, though, and Brian Easton volleyed over from 16 yards on the hour mark when better composure might have helped him to find the target and John Baird also headed high over as the ball fell to him with only the keeper to beat.
County were always threatening and Lawson brought a good save from Douglas in 67 minutes, closely followed by a timely Gary Irvine block from Iain Vigurs' driven shot.
However, two late goals were enough to give County the points, propelling them level on points with sixth-placed Aberdeen and leaving Dundee marooned at the bottom of the table 14 points adrift of St Mirren.