Leinster took advantage of an ill-disciplined first-half performance from Bath to reach the semi-finals of the European Champions Cup.
George Ford score a sublime solo try for Bath but five Ian Madigan penalties gave the hosts a 15-5 half-time lead.
Stuart Hooper scored Bath’s second try but Madigan’s sixth penalty put the hosts six points clear.
A Ford penalty cut the gap to three but a late Bath attack ended in a controversial penalty to Leinster.
The hosts, who are looking to become champions of Europe for a fourth time in seven years, were the more composed side at the Aviva Stadium in Dublin.
And although Leinster were out-scored two tries to none, Bath have only themselves to blame after a first half filled with a toxic mixture of indiscipline and knock-ons.
When they finally cut out the penalties and the errors they looked dangerous with ball in hand, with Ford pulling the strings and Anthony Watson a real threat from full-back, but Leinster had the know-how to hold on – albeit only just.
Presented with the chance to edge clear Leinster were happy to turn to Madigan and the sometimes erratic kicker was bang on the mark on five occasions in the first 40 minutes.
Bath finally switched on when Ford dummied his away past Jack McGrath and Devin Toner in midfield and rounded Rob Kearney on his way to scoring the opening try, but he took he shine off the score by missing the fairly simple conversion.
As the first half wore on Leinster began to get the upper hand in the scrums and with Watson also spending 10 minutes in the sin-bin, Bath were probably happy to still be in sight at 10 points down come half-time.
They were better after the interval and another classy break from England fly-half Ford gave captain Hooper the chance to power over.
Ford converted and, after Madigan had kicked his sixth penalty for Leinster, the Bath number 10 replied in kind for the visitors to set up a grandstand finish.
After a stop-start encounter the final 20 minutes were thrilling and the result was settled by the final attack.
Bath thought they had won a kickable penalty to level the scores as Sean O’Brien appeared to handle in the ruck, but the visitors’ replacement Matt Garvey was instead penalised for not coming in through the gate.
And once again it is three-time champions Leinster – packed with Irish Six Nations winners – who are into the last four and eyeing the biggest prize in European club rugby.
Rob Kearney; Fergus McFadden, Ben Te’o, Ian Madigan; Luke Fitzgerald; Jimmy Gopperth, Issac Boss; Cian Healy, Sean Cronin, Mike Ross, Devin Toner, Mike McCarthy, Jordi Murphy, Sean O’Brien, Jamie Heaslip (capt).
Richardt Strauss, Jack McGrath, Marty Moore, Tom Denton, Dominic Ryan, Eoin Reddan, Gordon D’Arcy, Zane Kirchner.
Anthony Watson; Horacio Agulla, Jonathan Joseph, Kyle Eastmond, Matt Banahan; George Ford, Micky Young; Paul James, Rob Webber, Kane Palma-Newport, Stuart Hooper (capt), Dave Attwood, Carl Fearns, Francois Louw, Leroy Houston.
Ross Batty, Nick Auterac, Max Lahiff, Matt Garvey, Alafoti Faosiliva, Peter Stringer, Sam Burgess, Tom Homer.