|Bath (8) 19|
|Tries: McConnochie 2 Pens: Priestland, Burns 2|
|Harlequins (5) 12|
|Tries: Dombrandt, Smith Cons: Smith|
Two tries from Ruaridh McConnochie saw Bath edge out Harlequins and move up to fourth in the Premiership table.
The England winger's first arrived after 11 minutes when he collected an inside pass from hooker Jack Walker.
Harlequins hit back after a slow start and Alex Dombrandt and Marcus Smith crossed to give the visitors a second-half lead.
But with 14 minutes to go, McConnochie raced down the touchline to add his second and hand Bath victory.
While a third successive win took the hosts into the play-off spots, a second straight defeat kept Quins in ninth, with only the consolation of a losing bonus point.
The home side started the game strongly and fly-half Rhys Priestland missed an early penalty before McConnochie's opener.
Walker threw into a line-out before collecting the ball from the jumper and slipping it inside to the winger who sprinted over.
Priestland added a penalty to put the home team into a deserved eight-point lead before Josh Matavesi had a try ruled out for a forward pass.
Struggling for any possession or territory, Quins' first try came out of nothing, as Dombrandt charged down a Priestland kick before collecting to score.
The visitors went down to 14 men early in the second half with replacement Brett Herron sent to the sin-bin by referee Tom Foley for a deliberate knock-on.
However, Bath struggled to create anything with the extra man and it was Quins who took the lead for the first time with Herron still on the sidelines.
Winger Gabriel Ibitoye offloaded inside to Smith. who beat the covering full-back Tom Homer with a marvellous sidestep to score. The fly-half added the conversion to put Quins ahead by four points.
Freddie Burns, on as a replacement, added penalties either side of McConnochie's second try as Bath showed their battling qualities to prevail.
Bath director of rugby Stuart Hooper told BBC Radio Bristol:
"We had to close the game out and come from behind but we're reaping the rewards of the effort put in during the week. That's what gets you on the right end of these tight games.
"We have to get better at maintaining pressure on the opposition but it's much easier to work on that off the back of a win.
"We haven't won three in a row since 2014-15 and that shows how inconsistent we have been, but also the application we have to be consistently winning now, especially with the disruption of the Six Nations."
Harlequins head of rugby Paul Gustard:
"(Rhys) Priestland and (Freddie) Burns controlled the field a lot better than we did.
"That's the experience of two international fly-halves - we've got two 20-year-olds who are still learning the game.
"The team is hurting, the coaches are hurting because it's tough to lose and to lose when we don't do the things we said we were going to do."
Bath: Homer; Rokoduguni, Willison, Matavesi, McConnochie; Priestland, Cook; Boyce, Walker, Judge, McNally, Stooke, Ellis, Louw (capt), Mercer.
Replacements: Dunn, Noguera, Nixon, Williams, Bayliss, Chudley, Burns, Wright.
Harlequins: Morris; Murley, Penny, Lasike, Ibitoye: Smith, Care; Garcia Botta, Baldwin, Kerrod, Young, Cavubati, Chisholm, Robshaw (capt), Dombrandt.
Replacements: Musk, Lambert, Swainston, Lamb, Evans, Kunatani, Saunders, Herron.
Referee: Tom Foley.