A 90th minute penalty by Felipe Contepomi earned Leinster an unlikely bonus point, but with 21 points at the top of Pool Two, it is unlikely they will be one of the top-four qualifiers.
It is only those privileged four teams who get a home draw in the quarter-finals, and already three teams have more than 21 points.
Leinster Coach Michael Cheika said afterwards: “I told the players before the game that if we didn’t get something out of this, we weren’t going to win the Heineken Cup.
“Gloucester played well. It was always going to be a difficult game down here.
“We’re down but we’re definitely not out.”
It will go down as a missed opportunity for the Dubliners if they have to travel away in the knockout phase because they are used to winning on the road in England in the Heineken Cup.
This was their ninth game on English soil in Europe and only their second defeat, yet for so long it was a game there for the taking.
Many people thought that as this was a dead rubber game for the home side, they wouldn’t care too much about it. What a mistake that was.
From first to last, the Gloucester forwards scrapped for every inch of grass and for every ball.
They started with a bang, with the strong, swirling winds behind them, and with Brian O’Driscoll already in the sin bin for handling in a ruck, the Gloucester pack rolled a line-out up to the Leinster line before they were awarded a penalty try by Welsh referee Nigel Owens.
Gloucester outside-half Willie Walker, who had earlier missed a simple penalty, added the extra points and Leinster knew they were in a battle.
Gloucester lost England scrum-half Peter Richards to the sin bin for an act of petulance after he threw the ball away at a penalty.
That gave Leinster a chance to get a grip on the forward battle and finally win some possession.
A great break off the back of a scrum on the home 10-metre line by Stephen Keogh almost led to a try by his back-row colleague Jamie Heaslip, but when he was hauled down just short, the astute O’Driscoll was on hand to pick up and snaffle a try at the post, which Contepomi converted to level the scores.
Leinster coach Michael Cheika would have been reasonably happy at the half-time score, although the loss with a knee injury of Ireland wing Shane Horgan on the stroke of half-time was a blow not only to his coach, but also Eddie O’Sullivan.
With the wind at their backs in the second half, Leinster were able to get some momentum into their game.
After 57 minutes Contepomi gave his side the lead with a penalty off the home 22.
Now things were looking up for the visitors and that home quarter-final tie was beckoning.
But then came some subtle changes to the Gloucester pack, with the French duo of Olivier Azam and Christian Califano entering the fray. Not only did they add new vigour to the home forward effort, but they combined to demolish the Leinster scrum.
It was Califano who was credited with the pushover try from another close-range line-out after 65 minutes that regained the lead for Gloucester and then the French loose-head prop ruined another Leinster scrum to pave the way for a chip-and-chase try by the left-wing Mark Foster.
Ryan Lamb’s touchline conversion looked to have taken the bonus point away from Leinster.
It was one-way traffic for the next 12 minutes as the game wore on into injury time.
Then came that Gloucester hand at a ruck which allowed Contepomi to kick the penalty which might yet still squeeze Leinster into the top-four qualifiers.
Scorers for Gloucester: Tries: C. Califano, M. Foster (pen try); Conversions: W. Walker, R. Lamb.
Leinster: Try: B. O’Driscoll; Conversion: F. Contepomi; Penalties: F. Contepomi 2.
GLOUCESTER: Balshaw, Bailey, Adams, Tindall, Foster, Walker, Richards, Wood, M. Davies, Nieto, Bortolami, Brown, Buxton, Hazell, Balding.
Replacements: Keil for Tindall (75), Lamb for Walker (41), Lawson for Richards (71), Califano for Wood (56), Azam for M. Davies (56), James for Brown (53), Boer for Hazell (65).
LEINSTER: Dempsey, Horgan, O’Driscoll, D’Arcy, Hickie, Contepomi, Whitaker, Wright, Jackman, Green, Hogan, O’Kelly, Keogh, Gleeson, Heaslip. Replacements: Kearney for Horgan (39), Corrigan for Wright (61), Blaney for Jackman (57), Finegan for O’Kelly (50). Not Used: Jowitt, Easterby, Warner. Sin Bin: O’Driscoll (13).
Referee: Nigel Owens (WRFU).