Sean Lamont celebrated his Scotland call-up by emerging as the Glasgow hero in their dramatic smash-and-grab act.
Borders: (3) 11
Pens: Vili, McRae
Glasgow: (3) 15
Tries: Lamont, A Bulloch
The winger's try seconds from time took the visitors ahead of Borders in the race to claim the country's second Heineken Cup slot behind Edinburgh.
Lamont pounced on a loose pass to streak to the line from 80 metres.
Alan Bulloch scored Glasgow's first try of the night, while Gareth Morton was the only man to cross the line for the home side.
Glasgow has made a brisk start and opened their account with a Calvin Howarth penalty after Dan Kane was caught offside.
Howarth then traded penalty misses with Morton before Borders launched a series of long-range raids.
Captain Kevin Utterson and Samoan number eight Semo Sititi embarked on strong surges with the latter being hauled down by Rory Kerr just a couple of paces short of the line.
The match was tense and jittery but Borders eased their fears when Tanner Vili took over the kicking duties to equalise with a well-struck kick.
Sititi was displaying his skills both in attack and defence and he again almost reached the line before being held in the corner.
Seconds later he backtracked to foil Glasgow scrum-half Sam Pinder, who had made a piercing break from halfway.
The contest burst into life immediately after the restart when replacement Bulloch justified his entry to the fray by crashing over to score.
But Borders replied in positive fashion to snuff out his effort through Morton.
Howarth was handed a clear chance to put the visitors back in front, but his penalty flew past the wrong side of the post.
The nerves were also showing at the other end when Morton fluffed an even easier shot at goal.
MacRae took over the boot duties to edge Borders in front - only for Lamont to have the final word, his try being converted by Howarth.
Borders: Gareth Morton, Cammie Murray, Jono Stuart, Kevin Utterson, Craig Moir, Tanner Vili, Gary Armstrong, Craig Dunlea, Stevie Scott, Geoff Cross, Scott MacLeod, Colin Stewart, Andy Rennick, Dan Kane, Semo Sititi.
Replacements: Ross Ford, Kelvin Todd, Doddie Weir, Tony Walker, Iain Fairley, Calum MacRae, Andy Turnbull.
Glasgow: Glenn Metcalfe, Rory Kerr, Graeme Morrison, Andrew Henderson, Sean Lamont, Calvin Howarth, Sam Pinder, Andrew Kelly, Simon Gunn, Euan Murray, Joe Beardshaw, Nathan Ross, Roland Reid, Jon Petrie (captain), Donnie Macfadyen
Replacements: Scott Lawson, Matthew Proudfoot, Andrew Hall, Andrew Wilson, Graeme Beveridge, Colin Gregor, Alan Bulloch.