Scarlets edged a European thriller at the Rec to stretch Bath's losing streak in the Champions Cup to eight games.
The visitors took the lead through Gareth Davies, scoring on his 200th Scarlets appearance.
But Bath led 14-10 at half-time thanks to Ruaridh McConnochie's try and the kicking of Ben Spencer.
Will Stuart went over to stretch Bath's lead, but Kieran Hardy's try and the boot of Leigh Halfpenny edged Scarlets ahead in a full-blooded encounter.
Bath were looking to end their worst run in European competition against a Scarlets side who won 35-17 on their last visit to the Rec in January 2018.
The home side were without Wales and former Scarlets fly-half Rhys Priestland because of a head injury, so Josh Matavesi started in the Bath 10 shirt.
But they had England's Anthony Watson, Jonathan Joseph, Stuart and Sam Underhill, and Wales' Taulupe Faletau back in the fold.
Scarlets were without injured Wales players Liam Williams, James Davies, Rhys Patchell, Johnny Williams and Johnny McNicholl, plus long-term casualties Ken Owens and Aaron Shingler.
But the Welsh side were bolstered by the return of their internationals from Autumn Nations Cup duty, including scrum-half Davies.
The Rec had 2,000 fans in attendance and Bath soon gave them something to cheer as scrum-half Spencer slotted an early penalty after Scarlets infringed at the breakdown following a McConnochie break.
Scarlets had not played since a Pro14 defeat at Ulster on 22 November, as their home game against Leinster a week later was called off after a small number of Scarlets players returned positive tests for Covid-19.
But the visitors looked anything but rusty as they claimed the game's opening try, as Halfpenny and Steff Evans combined on the left flank to send double-centurion Davies away for a score to mark his landmark day.
Halfpenny converted but was just short with his next effort, a penalty from just within his own half that did not quite have the legs.
Bath responded with a score that owed everything to slick inter-passing between forwards and backs, with Underhill giving the scoring pass to McConnochie to go over in the left corner for an unconverted try.
An earlier clash of heads had seen Faletau and Scarlets' Jake Ball sent for head injury assessments (HIA) and neither Wales international returned to the pitch, with Zach Mercer taking over at eight for Bath while Scarlets lock Morgan Jones came off the bench for his European debut.
Scarlets also lost Wales prop Samson Lee to another HIA before half-time, with Javan Sebastian his replacement in the front row.
Spencer added two more penalties, with Halfpenny replying with one of his own, to give Bath a 14-10 lead at half-time.
Scarlets started the second half with a spring in their step thanks to Halfpenny's second penalty and the arrival off the bench of British and Irish Lions centre Jonathan Davies, which saw Ryan Conbeer make way and Tyler Morgan shifted to wing.
But Bath soon replied with their second try, as prop Stuart was shoved over from close range after a series of drives at the Scarlets line.
The see-saw scoring continued when Scarlets replacement Hardy touched down almost under the posts after prop Rob Evans found a huge hole in the Bath backline and timed his offload to perfection.
Halfpenny's conversion nudged Scarlets 20-19 ahead with 13 minutes remaining, although the full-back was just wide soon after with a penalty that would have given some breathing space.
Another chance went begging when Hardy ripped through on the left, but his pass went behind Steff Evans and into touch rather than sending the winger to the line.
With five minutes left and Scarlets camped in the Bath 22, Underhill - whose breakdown battle with Jac Morgan had been one highlight in a match full of them - gave away a penalty that Halfpenny kicked.
Bath thought they had scored a winning try as they went on the charge from the restart, but Halfpenny managed to get under the ball to hold it up as a pile of Bath bodies dived over the line.
The home side kept up the battering as the clock ticked two minutes into the red and Spencer saw a half-gap, but his stretch to ground the ball was short of the line and Scarlets held on.
Scarlets coach Glenn Delaney told BBC Sport Wales:
"I'm really proud of the effort, the defensive tenacity at the end to win the game.
"It wasn't perfect, Bath were throwing everything at us and we want to be a Champions Cup side and to do that you have to deal with the big teams that are coming at you.
"That forward shift at the end was massive and well supported by the guys on the outside, just fighting to turn ball over any way they could."
Bath: Anthony Watson; Joe Cokanasiga, Jonathan Joseph, Cameron Redpath, Ruaridh McConnochie; Josh Matavesi, Ben Spencer; Beno Obano, Tom Dunn, Will Stuart, Josh McNally, Charlie Ewels (capt), Mike Williams, Sam Underhill, Taulupe Faletau.
Replacements: Jack Walker, Juan Schoeman, Christian Judge, Elliott Stooke, Josh Bayliss, Zach Mercer, Will Chudley, Semesa Rokoduguni.
Scarlets: Leigh Halfpenny; Ryan Conbeer, Tyler Morgan, Steff Hughes (capt), Steff Evans; Dan Jones, Gareth Davies; Wyn Jones, Ryan Elias, Samson Lee, Jake Ball, Sam Lousi, Blade Thomson, Jac Morgan, Sione Kalamafoni.
Replacements: Marc Jones, Rob Evans, Javan Sebastian, Morgan Jones, Josh Macleod, Kieran Hardy, Angus O'Brien, Jonathan Davies.
Referee: Alexandre Ruiz (France)
Assistant referees: Christophe Ridley (England); Sara Cox (England)
TMO: Ian Tempest (England)