Leinster snatched victory from the jaws of defeat as they scored 14 points in the final ten minutes to maintain their unbeaten record to guarantee themselves a quarter-final spot.
Despite gifting the Irish side a try after only two minutes with a misdirected lineout throw which Shane Jennings eagerly converted into a try, Bath battled their way back into contention and were the better team for long periods.
After that dream start, Leinster coasted for much of the first half and used the boot of Dave Holwell to keep their noses in front. After converting Jennings’ try, he responded to opposite number Chris Malone’s 35 metre drop goal with two penalties.  
But Bath used their driving lineout and marauding forwards to great effect and came up with a try from a lineout from skipper Steve Borthwick.
Barkleys’ conversion hoisted his number of successive successful kicks in recent weeks to 25 and he followed that up with a penalty three minutes later to level the scores just before the break.
Bath lost tightead prop Duncan Bell to the sin-bin just before the break but they were the dominant force even without him at the start of the second half.
And no sooner had he returned to the fray than the home side tightened the screw with a try from wing Brendon Daniel which Barkley converted.
With their noses in front Bath continued to take the game to the Pool leaders and another Barkley penalty after 71 minutes seemed to have wrapped up the result.   But then came Leinster’s rearguard action, spiced with a touch of luck and a few friendly bounces, and tries from Holwell and Malcolm O’Kelly, both converted by the outside half, turned the game on its head and sent Leinster into the last eight.