Cardiff Blues battled to a Heineken Cup quarter-final with a compelling win over Racing Metro.
But they travel to holders Leinster in the last eight after finishing second in Pool Two to Edinburgh, who secured a bonus-point win over London Irish.
Lloyd Williams and Alex Cuthbert (twice) went over for the hosts and Leigh Halfpenny did the rest, but they fell short of a bonus-point try.
Josh Matavesi and Sereli Bobo crossed for Racing's tries.
Jonathan Wisniewski, Sebastien Descons and Frans Steyn contributed 20 points between them with the boot.
Cardiff Blues were forced into a late change as hooker Rhys Thomas fell victim to a stomach illness to make way for Ryan Tyrell, with Marc Breeze coming on to the bench.
The home side were also without centre Jamie Roberts (knee) and preferred Gavin Evans to Gavin Henson as Casey Laulala's midfield partner.
Laulala was a regular threat in attack, but the Blues' first-half scoring efforts owed more to opportunism than creativity.
Visiting fly-half Wisniewski kicked an early penalty, but Steyn was overly relaxed before scrum-half Williams charged down his clearance to gather and score the opening try after seven minutes.
Halfpenny converted before he and Wisniewski exchanged penalties, but the hosts fell behind as Steyn launched a wonderful move that ended with full-back Matavesi going over in the corner.
Scrum-half Descons and Halfpenny continued the kicking duel with a shot each at goal.
Cuthbert then caused consternation in Racing's ranks with what looked suspiciously like a knock-on before he grasped the ball and beat the remaining defence for Halfpenny to convert.
But the attacking threat of the visitors that Blues joint head coach Gareth Baber spoke of in the build-up reared its head as wing Bobo finished off in style before Descons put the visitors ahead with the conversion.
Wales prop Gethin Jenkins departed after receiving treatment to a leg injury to create a worry ahead of the Six Nations.
Despite his absence the Blues' scrum forced a penalty which Halfpenny again landed but Steyn brought down the curtain on the opening period with a shot from inside his own half that gave the French club a 24-23 half-time lead.
The second period opened with another Cuthbert try - this time without controversy - as Racing failed to deal with Dan Parks' lofted kick and the towering wing, a member of the Wales squad, again gathered to race free.
Halfpenny converted from the touchline and he and Descons again exchanged penalties before Steyn banged over a second huge kick from inside his own half to leave the contest finely balanced.
Matavesi's hesitation ended with a failed drop-goal attempt and as the clock ticked down Halfpenny put over a close-range penalty following a Ma'ama Molitika drive.
Fortune favoured the hosts when Parks' kick went into touch via Jacques Cronje's chin. From the line-out Xavier Rush broke through only for Richie Rees to be held up inches short of the line.
With Edinburgh having scored a bonus-point try the Blues needed to match them to earn a home quarter-final, but they were unable to take two late chances, twice failing to secure their own throw on close-range attacking line-outs.
As a result, instead of hosting Clermont Auvergne in the last eight, they face a daunting trip to Dublin to face Leinster.
Cardiff Blues coach Gareth Baber: "We are absolutely over the moon to be in the quarter-final of the European Cup.
"We targeted being in it, and we have fulfilled our target. This competition throughout the whole weekend has thrown up little scenarios.
"Hats off to Edinburgh, they got their four tries today. We scored three, and it was always going to be as close as that."
Cardiff Blues: Leigh Halfpenny; Alex Cuthbert, Casey Laulala, Gavin Evans, Chris Czekaj; Dan Parks, Lloyd Williams; Gethin Jenkins, Ryan Tyrell, Scott Andrews, Bradley Davies, Paul Tito (capt), Michael Paterson, Xavier Rush, Sam Warburton.
Replacements: T James for Czekaj (67), R Rees for L Williams (53), J Yapp for G Jenkins (36), Hobbs for Andrews (42), Molitika for Tito (70).
Not Used: M Breeze, J Navidi, C Sweeney.
Racing Metro 92: J Matavesi; H Chavancy, F Steyn, F Estebanez, S Bobo; J Wisniewski, S Descons; M Tuugahala, B Noirot, B Sa, K Ghezal, F van der Merwe, J Leo'o, A Batut, S Chabal.
Replacements: G Arganese (for Noirot, 54), E Ben Arous (for Tuugahala, 45), J Orlandi (for Sa, 54) J Nailiko (for van der Merwe, 50), J Imhoff (for Wisniewski, 24), J Cronje (for Chabal, 52).
Not used: M Loree, R Vaquiin.
Referee: Andrew Small (England)