Wing Mack Hansen was held up over the Wales line by Murray, but Prendergast kicked a 67th-minute penalty that edged Ireland back in front before adding a long-ranger and a further three-pointer that saw them home, despite Ellis Mee's late effort that was ruled out following several replays.
A second Anscombe penalty further narrowed the gap, then Prendergast hit the post from distance and there were signs of Ireland losing their composure as Wales staged a strong finish to the opening 40 minutes.
He booted five penalties and a conversion in total, with number eight Jack Conan and full-back Jamie Osborne scoring tries, while Wales replied with touchdowns from captain Jac Morgan and wing Tom Rogers, plus two Gareth Anscombe penalties and a conversion.
Sherratt's Wales at times looked on course to deliver arguably the biggest upset in Six Nations history and there was late drama when debutant wing Ellis Mee went agonisingly close to a try that might have snatched it.
Ireland lost centre Garry Ringrose to a 20-minute red card midway through the second quarter and they trailed 13-10 at half-time, but they dug deep and prevailed through three Sam Prendergast penalties during the closing stages.