Harlequins (15) 29
Tries: Robshaw, Robson, Percival , T Williams Cons: Evans 3 Pen: Evans
Scarlets (3) 24
Tries: Stoddart, Rees, Evans Cons: S Jones Pens: S Jones
Quins scrum-half Danny Care is shackled at The Stoop
Harlequins held on for a bonus-point victory over the Scarlets to ensure a home Heineken Cup quarter-final.
Quins outclassed the visitors in the first half, with Chris Robshaw and George Robson going over for tries.
James Percival scored Quins' third before Scarlets clawed their way back into contention with tries from Morgan Stoddart and Matthew Rees.
However, Tom Williams scored the hosts' all-important fourth try before Gavin Evans grabbed a late consolation.
Ospreys' 15-9 victory over Leicester meant the Tigers went through as winners of Pool Three and also that Dean Richards' side will play their last eight encounter at The Stoop.
After a helter-skelter opening to the match, with both sides guilty of some aimless kicking, Stephen Jones gave the Scarlets the lead with a three-pointer.
Nick Evans, playing at full-back, levelled things before Quins went ahead through a try from flanker Robshaw, following a stirring catch and drive from centre Gonzalo Tiesi.
Shortly after, Robson trotted over unopposed before Evans added the extras to make it 15-3 at the break.
Robson's second-row partner Percival reached out to score Quins' third try after a barrelling run from Nick Easter and Evans slotted the conversion.
However, the Scarlets' comeback was triggered on 55 minutes by a magnificent pass from Regan King to Stoddart, who raced in from the halfway line to score.
Wales hooker Rees took advantage of a stolen line-out to score the Scarlets' second try, selling a sweet dummy before crashing over in the right-hand corner.
But the hosts kept a cool head, with substitute Tom Guest's jinking break leading to the bonus-point try from Williams.
The Scarlets had chances to make life very uncomfortable for Quins late on but wasted several chances, and Evans' 79th-minute try proved inconsequential.
Harlequins director of rugby Dean Richards:
"I said last year not to expect too much from us purely because we were very young as a team and quite naive when it came to playing in big matches and big venues.
"We have a lot more experience in the side now because the guys have progressed and matured as players and we have brought some in as well.
"Danny Care, Nick Easter, Mike Brown, Ugo Monye - they have been on England tours and played in front of 80,000 at Twickenham. Gonzalo Tiesi has played in a World Cup up to the semi-finals.
"We are a year older and a year more mature and it makes a big difference in terms of their understanding and confidence."
Harlequins: N. Evans, T. Williams, Tiesi, Turner-Hall, Monye, Malone, Care, Jones, Fuga, Ross, Percival, Robson, Robshaw, Skinner, Easter.
Replacements: Barry for Tiesi (41), Amesbury for Monye (36), Brooker for Fuga (49), Lambert for Ross (71), J. Evans for Percival (64), Guest for Robshaw (64).
Not Used: Poluleuligaga.
Scarlets: C. Thomas, Daniel, King, Davies, Williams, S. Jones, Roberts, John, John, Rees, Manu, Cooper, Day, Turnbull, D. Jones, Lyons.
Replacements: Stoddart for C. Thomas (41), Stoddart for C. Thomas (40), G. Evans for Davies (73), Cattle for Roberts (73), I. Thomas for John (49), Owen for Rees (68), MacLeod for Turnbull (54).
Not Used: Martens.
Ref: George Clancy (IRFU).