Paris - Four-time European club champions Toulouse failed to make the quarter-finals of this year's competition when they slipped to a 27-26 defeat to Montpellier in their final group match on Sunday.
Bath's 25-15 win over Glasgow saw them leapfrog Toulouse to finish top of Pool 4, leaving one place in the last eight still to be decided.
The Pool 1 showdown between leaders Clermont and second-placed Saracens later on Sunday will settle the issue.
Montpellier's victory means Clermont are already through, even if they lose, but Pool 2 runners-up Wasps could capitalise as one of the three best second-placed sides should Clermont triumph on home soil.
Toulouse, who are also struggling on the domestic front where they are only seventh in the Top 14 and currently out of the qualifying places for the play-offs, needed the win to go through.
And they had every chance to stamp their authority on a disappointing Montpellier side who had only racked up two points from their previous five games.
Toulouse even led 20-9 and appeared to be sailing to victory after 43 minutes, with converted tries from Clement Poitrenaud and Toby Flood on the board.
But two tries for Montpellier by Lucas Dupont, in the space of the next seven minutes, one of them converted, put the home side ahead by a single point.
Flood kicked two more penalties, but Montpellier replied on each occasion, first through fly-half Benoit Paillaugue and then Ben Lucas, as Toulouse led 23-21 and then 26-24.
But with 12 minutes left on the clock, Lucas stole victory with a final penalty to complete his tally of 11 points for the afternoon.