Leinster turned in a dazzling display to clinch the final qualifying spot for the Heineken Cup quarter-finals.
Bath (6) 23
Tries: Stephenson, Stevens
Cons: Malone 2
Pens: Barkley 2
Leinster: (21) 35
Tries: Horgan 2, Contepomi, Green, O'Driscoll
Cons: Contepomi 5
They ran in three early tries through Shane Horgan, Felipe Contepomi and Will Green to seize a 21-3 lead.
Horgan and Brian O'Driscoll added further tries - all five converted by Contepomi - before Michael Stephenson and Matt Stevens crossed for Bath.
Leinster's win earns them a trip to champions Toulouse in the knock-out stages while Bath will visit Leicester.
The visitors took the lead with a blistering score, Horgan racing over from the Bath 10-metre line to finish off a move which started when Contepomi took a quick tap in front of his own posts.
Contepomi slotted the simple conversion and although Barkley got Bath on the board with a long-range penalty Contepomi was soon back in the action.
The Argentine fly-half reads the game beautifully and he showed his awareness as he picked off an inside pass from Barkley before racing half the length of the field to score a try he converted himself.
After the Contepomi show it was the turn of Ireland centres O'Driscoll - who had an outstanding game - and Gordon D'Arcy.
They combined brilliantly from long range, with O'Driscoll sending prop Will Green over.
Contepomi converted and with an hour to still to play it was 21-3.
Barkley managed to land a second penalty for Bath but they then temporarily lost Andrew Higgins to the bin and ended the half trailing 21-6.
Bath struggled to raise their game after the break and it was nearly 20 minutes before they finally added a third Barkley penalty.
But no sooner had they scored then Leinster ran in their fourth try, Horgan finishing powerfully after a typically incisive break from O'Driscoll.
The Ireland captain then grabbed a try of his own, with Contepomi slotting both conversions.
Bath launched late rally and scored tries through Stephenson and Stevens, with Chris Malone converting both, but Leinster were long out of sight.
Bath head coach Brian Ashton:
"We didn't play well enough to deserve a home tie to be honest, so we've got to put up with it.
"The urgency and work-rate we insisted on just wasn't there early on.
"The bizarre thing was, it appeared in the last 15 minutes when you would have thought we would have been out on our feet."
Leinster head coach Michael Cheika:
"I get the chance of seeing Brian O'Driscoll every day and the way he's getting involved now.
"I got the chance to see this week how much he wanted to play well here. I could see the intensity in his eyes.
"Bath were smart and tried to change the game but we didn't let them play that much today. When we took our foot off the pedal in the last few minutes, they did well again."
Bath: Stephenson; Higgins, Cheeseman, Finau, Welsh; Barkley, Walshe; Flatman, Mears, Stevens; Borthwick, Grewcock; Beattie, Lipman, Delve.
Replacements: Malone for Barkley (73), Williams for Walshe (70), Bell for Flatman (40), Hudson for Borthwick (74), Scaysbrook for Delve (70).
Not Used: Dixon, Short.
Leinster: Dempsey; Horgan, O'Driscoll, D'Arcy, Hickie; Contepomi, Easterby; Corrigan, B Blaney, Green; Williams, O'Kelly; Jowitt, Gleeson, Heaslip.
Replacements: Kearney for Dempsey (40), Lewis for Contepomi (80), D. Blaney for B Blaney (80), Byrne for Green (66), Byrnes for O'Kelly (80), Miller for Jowitt (35).
Not used: O'Riordan.
Referee: Nigel Owens (WRU)