Connacht left it late to snatch a 19-13 triumph at Cardiff Blues to keep their faint European Champions Cup hopes alive.
The scores were locked at 13-13 heading into the final two minutes after Nick Williams burrowed over the Blues and Matt Healy crossed out-wide for Connacht.
But Tiernan O'Halloran landed a last-gasp drop-goal before Craig Ronaldson's long-range penalty at the death sealed an all-important victory to close the gap on the top six to 13 points.
John Cooney missed an early chance to give Connacht the lead with a long-range penalty.
But Gareth Anscombe made no mistake from the same distance to pit the Blues 3-0 ahead after 12 minutes.
The New Zealand-born Wales international stretched his side's lead to six points at the end of the first quarter with another penalty kick from an identical position.
Williams finally got the breakthrough the Blues were seeking after 28 minutes.
Willis Halaholo left a trail of defenders in his wake as he jinked 40 metres downfield, before the hard-hitting No 8 burrowed over from close range. Anscombe landed the conversion to make it 13-0.
But Healey pulled the Galway side back into the contest just before half-time. Hooker Tom McCartney broke free in midfield and almost got over the line himself before Jack Carty found Healy in space for an easy run-in.
Cooney cut the gap to just three points moments after the restart after Cardiff pushed early at a scrum.
Connacht kicker Cooney used the breeze to his advantage to level the scores at 13-13 with 17 minutes remaining after some ferocious defence earned a penalty.
Lam's men thought they had scored with 70 minutes on the clock when Niyi Adeolokun pounced on a loose ball over the line.
O'Halloran breezed though the Blues defence before offloading to the flying wing, but after consulting with the television match official, Marius Mitrea ruled he had knocked on.
But they had another golden chance to win it in the final 10 minutes when Jake Heenan's break moved Connacht two metres short of the line.
He then appeared out wide and made a half-break before offloading to Healy. All the wing had to do was collect the pass and dive over at the corner, but he spilled at the vital moment.
Carty then missed a drop-goal in the 78th minute, but O'Halloran landed one of his own a minute later before Ronaldson's long-range penalty sealed the 19-13 triumph.