Murtagh's efforts carried Ireland home by just one wicket, with a solitary ball to spare, in the ICC World Cricket League clash at Stormont after the Scots had looked set to snatch a vital victory.
Ireland's last pair needed nine from the last three balls when Murtagh suddenly changed the game by hitting Rob Taylor for a maximum down the ground and following up with another boundary.
Scotland had sensed victory when the dangerous Max Sorensen had been stumped off the bowling of Matt Machan in the penultimate over after a match-changing 31.
Prior to that Ireland had slumped from 95 without loss to 180 for eight in pursuit of 224, Majid Haq taking three for 26.
The defeat means Scotland, who play Ireland again in their final game on Saturday, can no longer climb into the eight-team competition's second qualification spot. They will have one last chance in a qualification tournament next year.
Ireland, the leaders of the WCL, have already booked their place at the 2015 World Cup in Australia and New Zealand.
Scotland posted 223 for nine from their 50 overs thanks largely to an unbeaten 91 from their South African-born captain Preston Mommsen.
Although wickets fell at regular intervals, Mommsen shared in important partnerships of 60 for the fourth wicket with Calum MacLeod (21) and 44 for the ninth with Safyaan Sharif (26).
Mommsen hit 10 fours in his 122-ball knock, holding the innings together after Machan's promising start was ended on 27 by Sorensen.
Somerset spinner George Dockrell, who struggled in the one-day clash with England earlier this week, was the pick of the Irish bowling with four for 24 from his 10 overs while Sorensen took two for 37.
Ireland captain William Porterfield, who scored a century against England, carried on where he left off in Malahide by rattling up 62 from 64 balls with 10 fours.
But he fell soon after the dismissal of his opening partner Paul Stirling (30) and Ireland struggled to recover the momentum.
Former captain Trent Johnston did weigh in with 24 from 34 balls but it was not until Sorensen got to work, putting on 29 for the ninth wicket with Murtagh, that hopes were truly revived.
It seemed over when Sorensen swung and missed after coming down the pitch to Machan, but Murtagh held his nerve.
- Sports & Recreation
- Max Sorensen
- Matt Machan