Robin Copeland's last-gasp try rescued a victory from the jaws of defeat as Connacht pipped Gloucester in a dramatic Heineken Champions Cup clash at the Sportsground.
Despite missing some key men, including Danny Cipriani who was pulled from the bench with a bug, Gloucester were on course to complete a Pool Five double over the Irish province thanks to tries from Gerbrandt Grobler, Mark Atkinson (2) and captain Lewis Ludlow.
Connacht's 10-7 half-time lead was turned into a 24-13 deficit as they stared at a European exit, but with Ludlow in the sin-bin, they delighted the home crowd with converted tries from Shane Delahunt and Copeland during a frantic final six minutes.
The result keeps both sides' quarter-final hopes alive, although defeating both Toulouse and Montpellier next month is a big ask. Failing to pick up a bonus point across the first four rounds, Connacht sit third in the table on eight points, with Gloucester second thanks to last week's home win and their haul of five bonuses.
"We made life hard for ourselves again," head coach Andy Friend told RTÉ Sport after the game.
"I certainly never doubt the character of this team and their fight.
"We work so hard for these tries if we can just cut out some of those errors we can really kick on because there is great belief in the team, there are some great footballers there and I think we are building nicely."
The onus was on Connacht to start the game quickly and their approach was suitably attacking. A high tackle yielded a penalty and young fly-half Conor Fitzgerald made no mistake for a deserved 3-0 lead, despite losing Eoin McKeon to a ninth-minute yellow card.
The momentum was all with Connacht and they began peppering the Gloucester line with phase after phase of pressure. The visitors were defending gamely, but not always legally. Hooker Todd Gleave was shown a yellow card as a glut of penalties saw referee Romain Poite lose patience.
The westerners elected for a scrum from the resulting penalty and, after a number of hard carries from his forwards, scrum half Caolin Blade made up for an earlier disallowed try when he sniped over for a 29th-minute touchdown which Fitzgerald converted.
Gloucester finally began to show some attacking incision of their own and were rewarded in the 33rd minute when ex-Munster lock Grobler powered over in the left corner with Billy Twelvetrees adding the extras.
Now just three points down, and after soaking up heavy pressure, the Cherry and Whites stung Connacht with a 50th-minute intercept try. As he sought to counter from deep from a John Porch turnover, Kyle Godwin's floated pass was picked off by Atkinson and his centre partner Twelvetrees converted for a 12-10 turnaround.
Fitzgerald punished a Ludlow offside by slotting over a penalty on the hour mark, but Gloucester roared back with a beautifully-crafted try.
Welsh flyer Louis Rees-Zammit made a searing break and stayed in play as his audacious behind-the-back offload found Callum Braley who dished off for Ludlow to gleefully dive over wide on the right.
Twelvetrees converted and Atkinson soon completed his brace in the right corner, taking out the covering Stephen Kerins with a clever dummy.
Suddenly, Gloucester had a commanding 11-point lead and Connacht were seemingly left to rue their own errors and missed opportunities.
A stunning finale awaited, though, as Ludlow was carded for an intentional knock-on and Connacht took advantage straight away.
Replacement hooker Delahunt went over for a try which Fitzgerald converted, and Tom Daly, another of the bench players, soared brilliantly to take down the all-important restart.
Revelling in their numerical advantage, Connacht returned to the Gloucester 22 with carry after carry, paving the way for centre Daly to crucially offload from the ground and send Copeland darting over for a classic team try.
With the conversion capping off Fitzgerald's 12-point contribution, the old Galway stadium erupted in celebration.