Dan Parks ruined Ireland's Croke Park farewell party by landing a last-minute penalty to ensure Scotland won 23-20 to avoid the Six Nations wooden spoon.
A tense and agonisingly close encounter was decided when fullback Rob Kearney was penalised for not releasing a kick by Parks and the Scotland first five-eighths stepped up to deliver the decisive blow.
To add to the drama, the winning points, struck from an impossibly tight angle, swerved out before floating back in between the posts.
The kick saw the brilliant Parks finish with an 18-point haul and the man of the match - his third in four games.
Ireland, which saw its hopes of completing a fifth Triple Crown in seven years shattered, looked to be control when captain Brian O'Driscoll cantered over in the 11th minute.
But the Scots, well drilled and implementing an intelligent gameplan, looked anything other than a team battling to avoid a third Six Nations wooden spoon since 2004 as they reeled the Irish back in.
Early in the second half they led 17-7, having withstood an early onslaught and replied with a muscular try from No.8 John Beattie - their first since Wales five weeks ago.
Their worst fears seemed to be unfolding as once again in this Six Nations their lead was eaten away, with Tommy Bowe's controversial 64th-minute try adding an air of perceived injustice.
Visiting fans were fans indignant after replays suggested Bowe failed to properly ground the ball for a touchdown that made the score 17-15.
Even after several viewings it was difficult to tell, making referee Jonathan Kaplan's failure to immediately consult the television match official utterly baffling.
But Scotland still had enough in the tank to hit back for its first win of the championship, a result that condemns Italy to bottom place.
Ireland bristled with intent as it set off at a frantic pace with slick handling creating an opening for Bowe only for the Ospreys winger to direct a poor pass at Keith Earls.
A second spilt ball by Gordon D'Arcy moments later saw another dynamic move break down, enabling Parks to produce a superb touchfinder that pinned back Ireland five metres from their line.
Handling errors continued to haunt the Irish as Jonathan Sexton became the latest player to fluff his lines.
The rising Leinster star made amends almost immediately by setting up the first try, linking with D'Arcy and drawing Hugo Southwell before providing O'Driscoll with a scoring pass that looked forward.
Sexton added the conversion but Scotland hit back four minutes later with only its third try of the Six Nations.
Hooker Ross Ford started a move that was finished by the rampaging Beattie, who swatted away tackles from D'Arcy, Geordan Murphy and Paul O'Connell as he bulldozed a 20-metre path to the line.
The trio of Irish defenders had a bemused look on their faces as Beattie placed the ball over the whitewash and Scotland celebrated wildly.
Sexton missed a penalty but Parks was more accurate in the 38th minute following a ponderous offensive spell from the Scots, who were dominating possession and territory.
Trailing 11-7, Ireland slipped further behind when Parks closed the first half with a well-struck drop goal.
A split pass by prop Cian Healy ensured Ireland continued to misfire in attack while a second missed penalty from Sexton resulted in nervous glances at the scoreboard.
In contrast to Sexton, Parks was kicking splendidly