Ireland recovered from opening-day defeat by England to beat Scotland in a Six Nations thriller at Murrayfield.
The Grand Slam champions were behind early on to a Greig Laidlaw penalty but tries from Conor Murray and Jacob Stockdale put the visitors ahead.
Sam Johnson went over for the hosts to narrow the gap to two points at the break as the Scots piled on pressure.
But Keith Earls scored after the hosts' defence was exploited just short of the hour to inspire the Irish to victory.
Gregor Townsend's Scotland saw plenty of the ball and appeared to deal well with losing full-back Stuart Hogg to injury midway through the first half.
But they could not build on their victory over Italy in round one, with Joey Carbery, a blood replacement for Johnny Sexton, turning in an outstanding performance for Joe Schmidt's side as their hosts could not reel them in late on.