Having trailed 17-13 at the break, Munster looked to be staring down a heavy defeat when Leinster, which is already sure of its place in the Final Series, went a further seven points clear early in the second half.
However, Devin Toner's stay in the sin bin handed Munster the initiative, and the visitors rallied through Keith Earls' superb try.
Ross Byrne's penalty nudged Leinster further ahead, but Andrew Conway's second try appeared to have saved Munster, only for Hanrahan to send his kick narrowly wide.
Edinburgh booked its place in the Final Series with a 30-15 victory over Scottish rival Glasgow Warriors, with Duhan van der Merwe's moment of brilliance the inspiration.
Glasgow held a slender 15-13 advantage heading into the final 20 minutes on Sunday (AEST), but Van der Merwe's superb run and offload teed up Nic Groom for his second try of the game.
Charlie Shiel's try sealed the win and Edinburgh will finish top of Conference B should it defeat the Warriors again next time out.
In the first Pro14 match back since the coronavirus-enforced hiatus, Scarlets, under the tutelage of new coach Glenn Delaney, turned on the style to run in five tries in a 32-12 hammering of Cardiff Blues in south Wales, boosting its Final Series hopes in the process.