Glasgow Warriors had a last-minute let-off as they edged a thrilling 1872 Cup second-leg tie against Edinburgh.
Jaco van der Walt's missed conversion after an Eroni Sau try preserved the hosts' one-point lead and moved them off the bottom of Pro14 Conference A.
Edinburgh were 10-9 up at the interval thanks to Jamie Farndale's try before Glasgow roared back as Matt Fagerson and George Turner both crossed.
A stunning Chris Dean score reduced the deficit and set up the dramatic finale.
But Danny Wilson's side survived to level the series at 1-1 and set up a decider as they attempt to claim the trophy for the first time in four years.
Glasgow move up to fourth in the standings, while Edinburgh remain second bottom of Conference B.
In the sides' previous meeting a fortnight ago, a turgid contest remained scoreless until the 65th minute before Edinburgh eked out a 10-7 win.
There was no delay in the action heating up this time, with Warriors' 21-year-old stand-off Thompson marking his first professional start with two penalties before Edinburgh responded with one from Jaco van der Walt.
Turner was sin-binned 34 after minutes when he thrust his shoulder into Grant Gilchrist's midriff off the ball, and Edinburgh quickly capitalised despite Huw Jones' superb try-saving tackle on Jamie Farndale in the far corner.
The visitors worked the ball across to the left before quickly switching back to the right as Blair Kinghorn and Dean fed the ball to Farndale, a late replacement for the injured Jack Blain, who this time was free to run in for the score.
Glasgow trimmed the deficit back to one just before the break as Thompson booted his third penalty, capitalising on a bizarre passage of play in which Edinburgh scrum-half Nic Groom booted the ball out, confusing the horn of a passing train for the half-time whistle.
And Glasgow then surged ahead with two scores inside the first 11 minutes of the second half.
Fagerson smashed over after patient build-up play before Turner barged through from a driven line-out following a yellow card for van der Walt for slowing up a Glasgow attack by not rolling away.
But the 14-man visitors hit back immediately as Dave Cherry pierced the line before Hamish Watson released Dean to score next to the posts.
Glasgow had to see out the final five minutes a man down when Jones was next to be shown yellow for illegally slowing an Edinburgh attack.
And Sau gave Edinburgh the chance to win the match with 90 seconds remaining when he powered down the line to score, but van der Walt's conversion from near the touchline crept wide.
Man of the match Thompson missed a last-minute penalty, but Glasgow secured just their third Pro14 victory in a difficult season.
Glasgow: H Jones; L Jones, Grigg, Fergusson, McLean; Thompson, Price; Seiuli, Turner, Fagerson, Gray, S Cummings, Wilson (capt), Gordon, Fagerson.
Replacements: Matthews, Lambert, Pieretto, Nakarawa, Harley, Dobie, Thomson, Smith.
Edinburgh: Kinghorn; Farndale, Bennett, Dean, Sau; van der Walt, Groom; Sutherland, Cherry, Berghan, Hodgson, Gilchrist, Bradbury, Watson, Mata.
Replacements: Willemse, Schoeman, Nel, Haining, Crosbie, Pyrgos, Chamberlain, Johnstone.