Johnny Sexton kicked a 77th-minute penalty to hand Ireland a 27-24 victory at Murrayfield after Scotland had overturned a 14-point deficit late on.
Ireland took a 24-10 lead thanks to tries from Robbie Henshaw and Tadhg Beirne as well as 14 points from the boot of Johnny Sexton, with Finn Russell scoring all of his side's points through a converted try and a penalty.
However, Scotland hit back late on, with Huw Jones and Hamish Watson going over to draw Scotland level before the Ireland fly-half won the game from the tee after replacement lock Ryan Baird forced a penalty at the breakdown.
It was at times a frantic game, but Scotland were badly let down by a misfiring lineout, while Ireland's work at the breakdown - culminating in Baird's important endeavour at the end - kept them in the ascendency.
Andy Farrell's side have moved into second place in the table after the win, while Scotland - who have a rearranged game against France to come later this month - are fifth after one victory from their first three games.
The result means France are now the only side capable of chasing down Wayne Pivac's Grand Slam-chasing Wales, with the two sides set to meet in Paris on Saturday.
Ireland took an early lead on the back of a break down the left and inside pass from James Lowe, with Russell failing to roll away at the tackle to hand Sexton the chance to make it 3-0 from the tee.
The visitors went further ahead when Sexton put a high ball into the in-goal area, and though Keith Earls couldn't collect under attention from two Scottish defenders, the ball went backwards and Henshaw supported well to gather for an 8-0 advantage following Sexton's missed conversion off the post.
Scotland were able to get off the mark in the 12th minute, with Tadhg Furlong pinged after the ball popped out the side of the ruck following a tackle from the prop. Russell slotted the kick to reduce the deficit, and then went on to give Scotland the lead with a converted try that was given after a TMO review.
Stuart Hogg charged down Gary Ringrose's clearance and kicked ahead before putting in a second kick infield - after the ball had bounced off his chin rather than his hand which was the subject of the check. Russell got on the end of Hogg's chip with his boot, and when Lowe tried to catch the ball it ballooned into the in-goal area, and the Scotland fly-half claimed it to score for a 10-8 lead after half an hour.
Ireland edged ahead again when Earls chased a Jamison Gibson-Park high ball to tackle Duhan van der Merwe, with Beirne arriving quickly to latch onto the ball and win the penalty - Sexton making it 11-10 with six minutes remaining in the half.
Russell had a chance to swing things back Scotland's way when Beirne was penalised for blocking at the lineout, but he sent the kick wide, and when Ali Price then went offside with time up in the half, Sexton duly converted for a 14-10 half-time lead.
Ireland were first on the scoreboard after the break, kicking to the corner from consecutive penalties to give Beirne the chance to crash over from close range for an easy Sexton conversion.
When Jamie Ritchie was spotted on the wrong side of a ruck, the referee awarded Ireland the penalty and Sexton pointed to the posts to make it a two-score game after 55 minutes.
However, a brilliant individual score from replacement Huw Jones brought Scotland back into the game, gliding between half-hearted tackles from Lowe and Hugo Keenan on the right side of the field before stepping past Gibson-Park to dot down on the hour mark.
Watson completed the comeback when he wriggled through several attempted tackles to find some grass over the tryline on the back of a lengthy period of pick-and-drives, and Hogg converted to make it 24-24 with five minutes remaining.
However, immediately off the restart, Baird charged down Price's kick, and though the Scotland scrum-half regathered, the replacement second rower got over the ball to win the penalty from which Sexton was able to win the game from out wide.