George Ford's late penalty clinched a 27-26 win for Bath over Harlequins, despite winger Ugo Monye scoring two tries for the hosts in his final home game.
Bath claimed a penalty for George Ford and try courtesy of Francois Louw in the first half but they still went into half-time trailing.
Harlequins replied with a penalty try, a try for Ugo Monye and a penalty for Nick Evans to give them the 15-10 lead at half-time.
The visitors scored two tries in the second half from Horacio Agulla and Leroy Houston and there was another penalty for Ford to win them the game.
Harlequins' Monye claimed a second try and there was another two penalties for Evans but they were cruelly denied the victory, as it finished 26-27.
Monye opened the scoring for Harlequins after only six minutes. Marland Yarde made a fantastic break before spreading the ball out wide to the winger who crashed over in the corner.
Harlequins were soon brought back down the earth when Jack Clifford was shown a yellow card on nine minutes.
However, the visitors only managed to claim one penalty courtesy of Ford in the ten minutes Clifford was off the field.
Bath's first try came after a superb break and offload by Houston which found Louw who took the ball over the line to put his team in the lead for the first time in the game.
Evans' penalty regained some points for the Harlequins before the home side were awarded a penalty try on 37 minutes which put them ahead 15-10 at half time.
Bath got the second half off to a better start when Agulla caught the ball on a beautiful line to cross for their second try on 42 minutes.
Quins replied with another two penalties for Evans to put them back in the lead. A series of quick passes found Houston and he crashed over the line to score to put Bath back in front.
The home side replied immediately with Monye's second try as the England winger then went off to a rousing reception on his final appearance at The Stoop after a stellar 13-year career, but the conversion was missed by Evans.
Ford kicked the penalty on 74 minutes to cruelly take the lead away from the home side and win the game 26-27.
Tries: Monye 2, Penalty Try
Pens: Evans 3
Yellow Card: Clifford
Tries: Louw, Agulla, Houston
Cons: Ford 3
Pens: Ford 2
Harlequins: 15 Ollie Lindsay-Hague, 14 Marland Yarde, 13 George Lowe, 12 Harry Sloan, 11 Ugo Monye, 10 Nick Evans, 9 Danny Care, 8 Jack Clifford, 7 Chris Robshaw (c), 6 Luke Wallace, 5 George Robson, 4 Nick Easter, 3 Matt Shields, 2 Dave Ward, 1 Mark Lambert
Replacements: 16 Rob Buchanan, 17 Seb Adeniran-Olule, 18 Darryl Marfo, 19 Charlie Matthews. 20 Netani Talei, 21 Karl Dickson, 22 Ben Botica, 23 Charlie Walker
Bath: 15 Anthony Watson, 14 Horacio Agulla, 13 Jonathan Joseph, 12 Kyle Eastmond, 11 Matt Banahan, 10 George Ford, 9 Peter Stringer, 8 Leroy Houston, 7 Francois Louw (c), 6 Sam Burgess, 5 Dominic Day, 4 Dave Attwood, 3 David Wilson, 2 Ross Batty, 1 Paul James
Replacements: 16 Rob Webber, 17 Nick Auterac, 18 Max Lahiff, 19 Matt Garvey, 20 Carl Fearns, 21 Chris Cook, 22 Ollie Devoto, 23 Tom Homer
Referee: Greg Garner
Assistant Referees: Ashley Rowden, JP Doyle
TMO: Rowan Kitt