Disappointing end to campaign for Ireland
Ireland 20 Scotland 23
Dan Parks ruined Ireland's Croke Park farewell party by landing a last-minute penalty to ensure Scotland avoided the RBS 6 Nations wooden spoon.
A tense and agonisingly close encounter was decided when full-back Rob Kearney was penalised for not releasing a kick by Parks and the Scotland fly-half 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, who saw their 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 number eight 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 their first win of the championship, a result that condemns Italy to bottom place.
Ireland bristled with intent as they 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 their 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 as he landed another three points.
A 15-metre rolling maul put Ireland back on the front foot and this time, after Scotland had been penalised for pulling it down, Sexton was on target.
The 24-year-old was substituted immediately after, however, with Ronan O'Gara stepping off the bench.
The tide appeared to be turning as a succession of Ireland players broke the gainline, moving to within five metres of the whitewash before desperate Scotland secured a crucial turnover.
In the 64th minute last year's Grand Slam winners drew level after they reacted smartly to a big overlap to send Bowe over for his disputed try, O'Gara adding the conversion.
Parks booted his fourth penalty to set up a nail-biting climax - one that he settled with his last-gasp penalty.