Pierre Bernard's last-gasp drop goal was enough for Bordeaux-Bègles to beat Gloucester 23-22 to reach the Champions Cup.
Bordeaux looked to have blown it having come from 16-0 down to lead in the second half thanks to two Metuisela Talebula tries, only to go behind once more with ten minutes remaining.
However Gloucester couldn't see out the final minutes and with a penalty advantage Bernard slotted a drop goal from 35 metres out to ensure that Bordeaux, rather than Gloucester will be in the Champions Cup next season.
Gloucester had dominated early on and were able to turn that into points thanks to the boot of Greig Laidlaw, who knocked over two penalties.
The home side missed a couple of chances to score the first try but it finally came through Henry Purdy, a late addition to the starting lineup after Jonny May had pulled out with illness.
It came after a great break from Charlie Sharples down the right, and when the ball came back James Hook spotted a lack of cover defence and chipped over for Purdy to collect and tiptoe over in the corner.
Laidlaw converted from the touchline, before adding a penalty to make it 16-0 as the Cherry & Whites threatened to run away with it.
Bordeaux finally got on the board with a penalty from Bernard, quickly cancelled out by another Laidlaw three-pointer.
Bernard added a second penalty five minutes before half-time and with three minutes remaining Talebula scored a stunning long-range try. It came after Ross Moriarty, Gloucester's stand-out player, had lost the ball in the Bordeaux 22.
Lionel Beauxis, also a late inclusion for the injured Sofiane Guitoune, popped the ball to Talebula, and he burst through a gap before sprinting 80 metres for the try.
That made it 19-13 at the break as Bordeaux gave themselves a chance, having looked dead and buried.
The second half saw Bordeaux come into the game more, and they deservedly scored another try just before the hour when Talebula went over for his second. It came after some brilliant handling from the visitors, opening Gloucester up thanks to a little dart by Bernard followed by a final pass from Julien Rey.
With Bernard's conversion Bordeaux led by a point, but they still had 20 minutes to hold out.
Both sides love to play attacking rugby, but it was their lack of tactical awareness that came to the fore in the closing stages, with Bordeaux going behind after trying to play out of their own 22 and offering Laidlaw a penalty from in front.
He made no mistake and it looked like it would be Gloucester's day. However Bernard, who last week had a shocking time from the boot as Bordeaux missed the Top 14 play-offs, had other ideas and held his nerve at the death.
Pens: Laidlaw 5
Yellow card: Afoa
Tries: Talebula 2
Cons: Bernard 2
Pens: Bernard 2
Drop goal: Bernard
Yellow card: Poirot
Gloucester: 15 Rob Cook, 14 Charlie Sharples, 13 Bill Meakes, 12 Billy Twelvetrees (c), 11 Henry Purdy, 10 James Hook, 9 Greig Laidlaw, 8 Ross Moriarty, 7 Jacob Rowan, 6 Sione Kalamafoni, 5 Tom Palmer, 4 Tom Savage, 3 John Afoa, 2 Richard Hibbard, 1 Nick Wood.
Replacements: 16 Darren Dawidiuk, 17 Yann Thomas, 18 Shaun Knight, 19 Elliott Stooke, 20 Dan Thomas, 21 Dan Robson, 22 Billy Burns, 23 Steve McColl
Bordeaux-Bègles: 15 Lionel Beauxis, 14 Metuisela Talebula, 13 Felix le Bourhis, 12 Julien Rey, 11 Blair Connor, 10 Pierre Bernard, 9 Heini Adams, 8 Peter Saili, 7 Hugh Chalmers, 6 Louis-Benoit Madaule, 5 Berend Botha, 4 Jandre Marais, 3 Patrick Toetu, 2 Ole Avei, 1 Jefferson Poirot.
Replacements: 16 Clément Maynadier, 17 Jean-Baptiste Poux, 18 Francisco Gomez Kodela, 19 Adam Jaulhac, 20 Matthew Clarkin, 21 Yann Lesgourgues, 22 Jayden Spence, 23 Baptiste Serin
Venue: Sixways, Worcester
Referee: Leighton Hodges (Wales)
Assistant referees: Dudley Phillips (Ireland), Rhys Thomas (Wales)
TMO: Jim Yuille (Scotland)