Bath's disappointing Heineken Cup campaign ended with a narrow win in Pool Three that finished Glasgow's European hopes.
Duncan Weir kicked Glasgow into a 3-0 lead but Bath went in front through Tom Biggs's converted interception try.
A penalty apiece made it 10-6 before Ben Skirving went over for a converted try to make it 17-6 after half-time.
Glasgow went ahead through tries from Tommy Semour and Rob Harley but two Olly Barkley penalties saw Bath home.
The Scottish visitors needed a win to retain their hopes of reaching the second-tier Amlin Challenge Cup as one of the third to fifth-ranked runners-up in the Heineken Cup pool stages.
And when, aided by the sin-binning of Bath scrum-half Chris Cook for killing the ball, they took an 18-17 lead with just over 15 minutes to play it looked as though they would do just that.
However, Barkley's brace of late penalties gave Bath only their second win in the Heineken Cup this season.
Bath rugby director Sir Ian McGeechan: "We got to 17-6 and were playing well so I was disappointed we didn't kick on, but to come back to finish strongly and get hold of the game again was pleasing and those two penalties saw us home.
"Having not seen out the game in Montpellier it was important to win and the manner of it, with us controlling the last seven or eight minutes, showed there have been some harsh lessons learnt.
"We have lost games we should have seen out and that was the pleasing aspect today, that we saw it out strongly."
Glasgow head coach Sean Lineen: "It's very disappointing. Our ambition is to win games and that was winnable. In the third quarter we showed our naivety, by playing in the wrong areas for too long and getting penalised.
"We were playing against a team with 14 men and we just needed to put a kick in behind them, and that is down to experience and we did not make good decisions.
"Once we had momentum we looked dangerous but it did not happen often enough, a losing bonus point is just not good enough."
Bath: Cuthbert; Carraro, Barkley, Banahan, Biggs; Donald, Cook; Beech, Dixon, Wilson, Attwood, Caldwell, Beattie, Mercer, Skirving.
Replacements: Vesty for Carraro (41), Heathcote for Biggs (55), Flatman for Beech (63), Mears for Dixon (55), Perenise for Wilson (63), Taylor for Beattie (67).
Not Used: Louw, Claassens.
Glasgow: Lamont; Seymour, Hogg, Morrison, Shaw; Weir, Cusiter; Welsh, MacArthur, Kalman, Gray, Kellock, Harley, Fusaro, Barclay.
Replacements: Murchie for Shaw (63), Wight for Weir (51), Pyrgos for Cusiter (64), R. Grant for Welsh (69), Hall for MacArthur (51), Reid for Kalman (43), Ryder for Kellock (32), R. Wilson for Fusaro (63).
Ref: Christophe Berdos (France).