George Turner's late try proved decisive as Glasgow edged an attritional opening 1872 Cup derby against Edinburgh at Scotstoun.
Warriors trailed 9-6 heading into an explosive final 15 minutes in which the lead changed hands three times.
Glasgow pair Ali Price and Turner powered over either side of a Blair Kinghorn score for the visitors in a match that featured five yellow cards.
Glasgow stay fourth in Pro14 Conference A, two points behind Cheetahs.
Defeat, with a losing bonus point, leaves Edinburgh third in Conference B, a point behind Connacht and five adrift of Munster.
Edinburgh have won the 1872 Cup in the last two seasons, but Glasgow have now won back-to-back meetings. The sides meet again at Murrayfield on 28 December in the second part of their festive double-header.
Late drama lights up a strange game
This was tight, attritional and error-strewn rugby. It was more than stop than start for the most part, more hard grind than anything resembling accuracy and ambition.
Four yellow cards all came before the game sparked into life with about 15 minutes to go - a fifth yellow came later on. The class arrived in the end through Adam Hastings, Huw Jones and Price, but Scotstoun suffered through an hour of ugly stuff beforehand. No sooner had we finally seen one bit of excellence we saw another when Edinburgh came to life with Kinghorn's score.
The endgame was exciting, particularly so when Glasgow drove over the winning score but there was much to endure beforehand.
As an illustration of the lack of authority on show in the first half alone Glasgow had 36% possession and 36% territory, they gave up 10 penalties and one yellow card and lost 50% of their lineout ball and still Edinburgh couldn't take advantage. The half ended 6-6, two penalties apiece from Hastings and Simon Hickey.
For vast parts of the night the loudest roars were reserved for referee Ben Blain when he repeatedly pinged Glasgow at the breakdown. Defences were on top. That was all you could say for it as a spectacle.
There were two moments of enterprising rugby in the entire first half, when Darcy Graham stepped Kyle Steyn, chipped ahead and got taken out but Ruaridh Jackson, who got binned. The 10-minute spell ended 3-3. The second moment when the game threatened briefly to flicker into life came when Fraser Brown put Scott Cummings in behind the Edinburgh defence.
The lock galloped away and had George Horne on his shoulder. When Glasgow went wide, Bill Mata came up offside, knowingly and cynically. He became the second man in the bin. Glasgow had a penalty. In what always promised to be a game of tiny margins the sensible option would have been to go for the posts and get up the tunnel with a lead.
Glasgow went for the scrum and got penalised. Instead of going off with a psychological lift they ceded that advantage to Edinburgh. The scrap carried on. In a microcosm of the game, Glasgow had an attacking lineout inside the Edinburgh 22. They banged away for an age. Phase upon phase, then got done at the breakdown. Hamish Watson turned it over from what looked suspiciously like an offside position. Cue more anger from the home crowd.
There was no shortage of fury. Minutes later Brown was hit shoulder-first by Stuart McInally, the two Scottish hookers at the centre of the game's most controversial moment. Brown was falling when taken by McInally and that was the mitigation that saved the Edinburgh man. What could have been a red was correctly called as a yellow by Blain. Scotstoun begged to differ.
Mata returned - his spell in purgatory ended 0-0 - and as soon as he came back another one went, a fourth yellow, this time for substitute Turner. He was penalised for a shoulder-first tackle; a fairly harsh call.
Most at Scotstoun had probably started to give up all hope of seeing some brilliance but 15 minutes before the end it finally arrived. Hastings little dink over the top of the Edinburgh was a delight. Perfect weight, perfect length. Jones caught it and went like the clappers for the posts before offload to Price to score.
Hastings' conversion made it 13-9. At last Scotstoun had something to get its teeth into. And then they had plenty to cringe about. Kinghorn's score in the corner had much to do with the patience and precision of his forwards, Jamie Ritchie in particular, and his own innate finishing. The full-back stepped off his wing and went over. Jaco van der Walt's conversion was good and Edinburgh led 16-13 with nine minutes left.
Edinburgh's Nic Groom became the fifth man in the bin soon after and Glasgow's response was game-defining, They launched a maul and fired it over the Edinburgh line, Turner on the end of it. Hastings' conversion from the touchline was outstanding and pivotal. Had he missed then Edinburgh could have landed a drop goal or booted a penalty to win.
As it was they needed a try. Glasgow's defence stood up to them in the closing minutes. Glasgow needed this, big-time. A strange game, but a precious victory for Dave Rennie's side.
Glasgow Warriors: Jackson, Seymour, Jones, Johnson, Steyn, Hastings, G Horne; Seiuli, Brown, Z Fagerson, Cummings, Gray, Harley, Gibbins (capt), Wilson.
Replacements: Turner, Kebble, Nicol, Ashe, Gordon, Price, Grigg, Matawalu.
Sin bin: Jackson, Turner
Edinburgh: Kinghorn, Graham, Bennett, Taylor, Van der Merwe, Hickey, Pyrgos; Shoeman, McInally, Ceccarelli, Toolis, Gilchrist, Bradbury, Watson, Mata.
Replacements: Willemse, Bhatti, Berghan, Carmichael, Ritchie, Groom, Van der Walt, Johnstone.
Sin bin: Mata, McInally, Groom