Bath snatched a late victory at Leicester Tigers and the final European Champions Cup place in an epic game.
Jacques van Rooyen's close-range score and Rhys Priestland's conversion completed a second-half comeback to see them edge out Sale into sixth place.
Leicester had earlier led by 14 points with tries by Ellis Genge, Brendon O'Connor and Clayton Blommetjies and 16 points from the boot of George Ford.
Anthony Watson, Joe Cokanasiga and Beno Obano also crossed for Bath.
It was a thrilling send-off for departing Bath director of rugby Todd Blackadder, who saw his side trail for the majority of the contest.
They chipped away at a fragile Leicester side in the closing quarter as second-half tries from Obano and Van Rooyen eventually saw them wipe out Tigers' 26-15 half-time lead.
Geordan Murphy's men were unable to close out the game at the end of a frustrating season that saw them finish second from bottom with just seven wins in 22 matches.
It had looked like being the perfect send-off for seven of their squad on their final appearances when Genge, O'Connor and Blommetjies crossed to keep them ahead.
But, for the first time in their Premiership history, Leicester were consigned to a fourth successive home defeat as Bath rallied in the closing quarter.
The Blue, Black and Whites had looked like missing out on the top six with Sale Sharks beating play-off bound Gloucester.
In the end, three sides finished on 56 points from fourth to sixth in the table and Bath edged out seventh-placed Sale by just a point courtesy of Van Rooyen's bonus-point securing try.
Tigers head coach Geordan Murphy told BBC Radio Leicester:
"I feel sick. No excuses really. The boys put in a really good shift. But some big decisions went against us again.
"That's the nature of when you're down on your luck, everything seems to go against you.
"Bath scored a try early and everyone in the stands seemed to think it was a forward pass. Freddie Burns thought so too and took a quick conversion, but the television match official was happy with it.
"Then we had one ruled out for Clayton Blommetjies when I felt he offloaded before his foot went out of touch. Then when it got close down to the wire, short of confidence, we just needed more composure.
"Overall, I'm devastated for the lads. I thought they were really committed under difficult circumstances. But, unfortunately, that's probably indicative of how our season's been."
Bath director of rugby Todd Blackadder told BBC Radio Bristol:
"I'm so proud of the boys. Any other team could have lost this game. They just showed immense character and belief.
"We talked at half-time about what we needed to do and they came out and played right up to the 80th minute.
"Leicester won the collisions and played really well in taking it to us. We had slow ball and just couldn't play on top of them.
"After half-time we recalibrated and broke through and kept asking questions of their defence that eventually paid off.
"We've come a long way this season and passed a massive character test. I'm so pleased we're in the top six as this squad is only going to get better with Champions Cup rugby to play."
Leicester: Worth; Aspland-Robinson, Smith, Eastmond, Blommetjies, G Ford, Harrison; Genge, T Youngs (capt), Cole, Spencer, Kitchener, Fitzgerald, O'Connor, Kalamafoni.
Replacements: Polota-Nau, Gigena, Heyes, Wells, Mapapalangi, White, Hardwick, Sarto.
Sin-bin: Aspland-Robinson (44 mins)
Bath: Watson; Cokanasiga, Joseph, Wright, McConnochie; Burns, Chudley; Obano, Dunn, Lahiff, Douglas, Ewels (capt), Ellis, Louw, Mercer.
Replacements: Batty, Van Rooyen, Nixon, Stooke, Walker, Fotuali'i, Priestland, Rokoduguni.
Sin-bin: Lahiff (38 mins)
Referee: Craig Maxwell-Keys.