Ryan Grant scored two tries as Glasgow secured a Pro12 play-off spot with a thrilling bonus-point win over Ospreys.
The Scotland prop plunged over either side of a Sean Maitland score in a first half dominated by the hosts.
The visitors, who are now in danger of slipping out of the top four, improved after the interval with Cai Griffiths and Sam Lewis touching down.
But Niko Matawalu scored from a quick tap penalty and DTH van der Merwe added a late breakaway try for Glasgow.
Gregor Townsend's side move up to second in the table but will be overtaken if Leinster win at Zebre on Sunday.
It was a huge game for both sides but Glasgow were much sharper and showed a greater appetite in the opening exchanges and could have been out of sight by half-time if Duncan Weir had not missed three straightforward penalties.
Dan Biggar kicked the Ospreys in front before John Barclay looked certain to score on his 150th Glasgow appearance, following a great break and offload from Maitland.
The flanker, who is moving on at the end of the season, charged over the line near the posts but some sterling defensive work by Justin Tipuric resulted in the TV match official ruling that he had been held up.
However, Glasgow did get the ball down from the resulting scrum, with Grant bundling over from close range, while Weir added the extras.
The TMO was called upon again soon after when an impressive burst of pace from Maitland saw the winger get a hand on a clever kick over the top from the inventive Matawalu and this time the crowd were able to celebrate.
Weir missed the conversion from a difficult angle on the touchline.
Ospreys responded with a prolonged period of possession as they probed for an opening but some fierce tackling kept the defending champions at bay.
And a slick passing move, started by a powerful surge from Sean Lamont, and included two switches from the back of the hand, culminated with Grant making a short dash for the line to extend Glasgow's lead.
Weir landed the conversion and knocked over a penalty after Rob Harley had been taken out in the air from a line-out to make the score 22-3 at the interval.
Grant's eventful evening took another twist when he was yellow carded, along with opposite number Adam Jones, as referee Alain Rolland lost patience with repeated nonsense at the scrummage.
Ospreys then took a grip on the game, with Griffiths squirming over for a try, and there was a let-off for Glasgow when a knock-on was awarded five metres from the line when the ball clearly struck the knee of a white-shirted player.
Glasgow were in danger of losing their way but some quick thinking from Matawalu got the hosts back on track and secured a bonus point.
The Fijian scrum-half took a tap penalty from 15 yards and waltzed through a series of lazy challenges before nonchalantly placing the ball over the line.
Weir was again errant with the boot before he suffered what looked like a serious leg injury and had to be stretchered off after lengthy medical attention.
Ospreys had chances to stay in touch but twice lost line-outs in the corner before Sam Lewis ghosted through the home defence to touch down under the posts.
Another slaloming run from Matawalu set up a penalty for replacement Peter Horne to knock over and an explosive break and looping pass from Grant allowed Lamont, then Stuart Hogg to build up a head of steam only for the full-back to be stopped just short.
Graeme Morrison, who is also leaving Glasgow at the end of the season, produced a delicate side-step as the normally resolute Ospreys tired but the centre inexplicably lost his grip on the ball to be denied a farewell score.
There was to be one more try under the Scotstoun floodlights and it came when substitute winger Van der Merwe was left in acres of room in the final minute.
Glasgow: Hogg, Maitland, Dunbar, Morrison, S. Lamont, Weir, Matawalu, Grant, MacArthur, Low, Swinson, Kellock, Harley, Barclay, Strauss.
Replacements: van der Merwe for Maitland (69), Pyrgos for Morrison (76), Horne for Weir (63), Hall for MacArthur (55), Kalman for Low (57), Ryder for Swinson (50), Fainga'anuku for Harley (43). Not Used: Wilson.
Ospreys: Fussell, R. Jones, Isaacs, Spratt, John, Biggar, Fotuali'i, D. Jones, Hibbard, A. Jones, A. Jones, Evans, King, Tipuric, Bearman.
Replacements: Webb for R. Jones (63), Morgan for John (69), Baldwin for Hibbard (18), M. Thomas for A. Jones (76), Lewis for Evans (57), Griffiths for King (43). Not Used: J. Thomas, S. Thomas.
Referee: Alain Rolland (IRFU)
Assistant Referees: Peter Allan, David Changleng (both SRU)
Citing Commissioner: Iain Goodall (SRU)
TMO: Jim Yuille (SRU)