Tom de Glanville's stoppage-time try helped Bath beat 14-man Bristol 29-27 in a thrilling West Country derby.
Harry Thacker scored twice before Siva Naulago crossed to put Bristol 21-0 up after 15 minutes, before the Bears had Naulago sent off in the 34th minute.
Semesa Rokoduguni scored for Bath soon after, and second-half tries from Jonathan Joseph, Taulupe Faletau and Joe Cokanasiga levelled the scores.
Callum Sheedy kicked Bristol back in front only for De Glanville to win it.
There were only four minutes to go when Sheedy slotted the penalty which had given the Bears back the lead but Bath never gave up hope and took advantage of the visitors finishing with 13 men when Theo Strang was sent to the sin-bin for taking out Josh Bayliss deep in the Bristol 22.
The victory, coupled with Worcester's 43-12 loss at London Irish, means Bath move off the bottom of the table while Bristol remain 10th in the Premiership.
Bath were left shell-shocked as Bristol blasted them away in the opening 15 minutes - Thacker twice forced his way over from line-out mauls inside the first six minutes before Naulago's excellent finish in the corner.
It could have been worse for Bath had Alapati Leiua not stepped into touch as he went in shortly before the third try or Thacker not been held up over the line midway through the half.
But Bristol's discipline deserted them after half an hour - Thacker was yellow-carded after a series of penalties before the hosts were held up over the Bears' try line.
Naulago then received a red card after hitting Will Butt in the face with his shoulder and will surely face a long ban having just returned from a suspension for a similar offence against London Irish last month.
With the Bears down to 13 men, Rokoduguni went in after taking a De Glanville pass before Sheedy kicked a Bristol penalty on the stroke of half-time.
Bath's hopes were boosted just after the break when Sheedy was sin-binned for a deliberate knock-on, and against 13 men Bath struck as Joseph went over in the corner and Wales number eight Faletau powered in from close range two minutes later.
Bath thought they had gone ahead with 18 minutes left, but Cokanasiga's foot brushed the line as the hosts started to take control with the extra man, and the former England winger made no mistake 10 minutes later as he dived into the corner, although Danny Cipriani's missed conversion meant the scores were level at 24-24.
Bristol's Fiji star Semi Radradra was superbly stopped under the posts two minutes later and a tired Bears defence could not hold out after being reduced to 13 following Strang's yellow card as the ball was spun out to De Glanville, who found space on the right to go over and send the Rec into raptures.
Bath head coach Neal Hatley told BBC Radio Bristol:
"I'm so pleased for the supporters who've come out and again been brilliant and I'm pleased for the boys.
"We talked in the week about staying in every play, making sure that were into everything and so to score when the clock's well into the red, those are the moments we've been talking about in training.
"It was a horrific start. 21-0, we didn't deal well with their drive, but I thought as the second half went on we got better and better.
"We stopped the drive, that was a big weapon for them, and once we took that away from them they had to play away from that and that brought us into the game."
Bristol director of rugby Pat Lam told BBC Radio Bristol:
"We started off really well and then unfortunately a red card and three yellow cards, that's 20-odd minutes defending with 13 men and a lot of the rest of the game with 14 men.
"But saying that I'm proud of the boys, we almost snuck that game out and at 24-all we were just hanging in there a lot of times on defence, but the boys just kept getting up.
"I thought the yellow card at the end was unfortunate, the ball went forwards so the ball was never on anyway, but it is what it is and with everything we faced that could have been a wonderful win, but at the end of the day I'm still proud of the guys."
Bath: De Glanville; Rokoduguni, Joseph, Clark, Butt; Cipriani, Spencer; Morozov, Doughty, Rae, Williams, Richards, Bayliss (capt), Underhill, Faletau.
Replacements: du Toit, Boyce, Fia, Spencer, Coetzee, Simpson, Bailey, Cokanasiga.
Bristol: Lloyd; Naulago, Radradra, Frisch, Leiua; Sheedy, Lennon; Woolmore, Thacker, Armstrong, Attwood, Joyce (capt), Vui, Heenan, Jeffries.
Replacements: Byrne, Y Thomas, Challenger, Luatua, D Thomas, Strang, Eden, O'Conor.
Sent off: Naulago (34)
Sin-bin: Thacker (31), Sheedy (43), Strang (80).
Referee: Luke Pearce