Bristol beat Gloucester 36-21 in the West Country derby but fell short of a place in next season's Champions Cup.
Siva Naulago and Harry Thacker scored early for the Bears, with Ollie Thorley crossing for Gloucester.
Magnus Bradbury and a brace from Semi Radradra gave Bristol the win but Jonny May's score and a late penalty try crucially closed the gap.
Bath's win over Saracens means they move above Bristol into eighth in the Premiership on points difference.
Bristol end the season in ninth, level on league points with Bath but below them because of a deficit of nine points fewer scored, and are confined to play in the Challenge Cup next season for the second consecutive campaign.
The Bears dominated possession during the opening 10 minutes, twice reaching Gloucester's 22 but seeing the ball turned over before finally getting on the scoresheet.
With Gloucester penalised at the scrum, it gifted Bristol the chance to kick to their five-metre line and from the line-out Thacker spun free of the maul before Naulago jumped over the line on the blindside.
Thacker crossed for his own try a few minutes later on his 100th appearance for the club, as another Gloucester penalty allowed Bristol to kick to the corner. The resulting driving maul was more straightforward with the hooker diving over from the back for his 11th try of the campaign.
Gloucester eventually retaliated with their first real attack in a sleek passage with the ball worked out wide as the Bristol defence was pulled in, allowing Thorley to run over unopposed in the corner.
An AJ MacGinty penalty gave the hosts a 10-point lead at the break and the Bristol deluge continued. Bradbury was next to cross from close range before winger Radradra - one of six players in Bristol's starting 15 playing their final game for the club - added the vital bonus point, bouldering over Adam Hastings under the posts.
Yet against the run of play, Bristol lost the ball deep in the opposition half and Gloucester quickly counter-attacked, setting off May to run clear and score.
A second try from Radradra with four minutes to go seemed to briefly put Bristol narrowly in the driving seat in the table over their neighbours.
Yet with Bath continuing to score at the Recreation Ground and the clock in red at Ashton Gate, Gloucester were the ones pushing for a score. Star full-back Charles Piutau was then yellow carded for a deliberate intercept and sent to see out his final few minutes in a Bristol shirt from the sin-bin, and the Cherry and Whites were given a penalty try.
Having started 2023 in the top four, this was Gloucester's sixth straight loss and means that they end the campaign second from bottom and without a win on the road since 21 October.
Bristol: Piutau, Naulago, Radradra, Williams, Lloyd, MacGinty, Randall; Y. Thomas, Thacker, Sinckler, Batley, Vui, Luatua (c), Jeffries, Harding.
Replacements: Capon, Woolmore, Lahiff, Bradbury, Heenan, Uren, Bedlow, O'Conor.
Sin-bin: Charles Piutau (80+3 mins)
Gloucester: Carreras, May, Harris, Atkinson, Thorley, Hastings, Varney; Vivas, McGuigan, Gotovtsev, Clarke, Alemanno, Clement, Ludlow (c), Morgan.
Replacements: Blake, Rapava-Ruskin, Ford-Robinson, Jordan, Thomas, Meehan, Twelvetrees, Hearle.
Referee: Wayne Barnes