Borders gave their long-suffering fans a roller-coaster ride as they bounced back from yet another Celtic League slip at Netherdale.
Borders (16) 40:
Tries: Stuart, Moir, Vili, MacLeod.
Cons: Vili 4.
Pens: Vili 4.
Warriors (13) 29:
Tries: McPhillips, Bracken.
Cons: McHugh 2.
Pens: McHugh 5.
The home side raced off to make the perfect start, rattling up 13 points in as many minutes - only for Connacht to surge ahead.
But late touchdowns by Jonno Stuart and Tanner Vili teed up a crucial win in the scramble for a Heineken Cup slot.
Vili was in fine kicking form, with four penalties and four conversions.
Winger Craig Moir broke the deadlock after just 90 seconds with a fine try created by stand-off Vili in the wake of a lineout steal.
Vili landed the conversion from a wide angle - then rocked the Irishmen by firing over two penalties in quick succession.
Connacht got their side of the scoreboard clicking as Mark McHugh slotted a penalty to ease their jitters.
Vili restored the Borders advantage with an indentical score - only for the locals to come under heavy pressure after number eight Semo Sititi was sent to the sin-bin for a mystery offence.
The defence held firm against the Connacht resurgence until two minutes before the interval when their top scorer, Conor McPhilips, squeezed over in the corner with McHugh converting.
Even worse was to come for the Borders as the province stepped up another gear.
A pair of penalties by McHugh tied the contest before a drive-over try by prop Peter Bracken, goaled by McHugh, put Connacht ahead for the first time.
And the ace marksman struck again with his fourth penalty to leave the Scots in a deep hole.
But they kept their hopes alive with a disputed try by Scott MacLeod, converted by Vili - with McHugh adding three more points to the Connacht tally.
Then Stuart and Vili completed the revival, Vili also converting the first and adding a last-gasp penalty.
Borders: Sititi, Kane, Rennick, Stewart, MacLeod, Cross, Scott, Dunlea, Armstrong, Vili, Moir, Utterson (Capt), Stuart, Nikki Walker, Murray.
Replacements: Landells, Todd, Weir, Tony Walker, Fairley, MacRae, Turnbull.
Connacht: M. McHugh; C. McPhillips, S. Moore, T. Allnutt (captain), W. Munn; D. Hewitt, M. Walls; D. McFarland, J. Fogarty, P. Bracken; D. Browne, A. Farley; M. Swift, M. Lacey, J. O'Sullivan.
Replacements: H. Bourke, A. Clarke, C. Short, J. Muldoon, C. O'Loughlin, E. Elwood, J. Meagher.