Joe Marchant scored two tries as Harlequins narrowly beat Gloucester in front of 77,567 at Twickenham.
Marchant’s first helped Quins to an 11-3 half-time lead and Jack Clifford extended the advantage while Gloucester wing Jonny May was in the sin-bin.
Gareth Evans barged his way over from close range to give Gloucester hope.
Centre Marchant added his second try to make it 28-10 in Quins’ favour, before Gloucester scores from James Hook and Motu Matu’u set up a tense finish.
Quins ended the match with 14 men after Clifford was shown a yellow card and Gloucester pressed for a match-winning try, but the home side held on to move into the Premiership’s top six.
The game began in cagey fashion and was scoreless until Marchant found himself with plenty of room to finish with ease on 27 minutes.
But, as a contest, it was completely different in the second half as Gloucester crossed three times and could easily have scored another.
Before eventually scoring after combining well with May, Hook thought he had another try following a mistake from Marland Yarde, who dropped a simple catch beyond the try line allowing Hook to pounce, but the officials found that Hook had been offside.
The closing moments also offered drama and Gloucester were aggrieved not to have been awarded a penalty with seconds remaining, as replays showed Quins captain Danny Care intercepted from an offside position.
But the visitors had to settle for a losing bonus point that lifted them above Newcastle into eighth.
Harlequins: Brown; Yarde, Marchant, Roberts, Visser; Jackson, Care; Marler, Buchanan, Sinckler, Merrick, Matthews, J Chisholm, Wallace, Clifford.
Replacements: Ward, O Evans, Collier, South, Naoupu, Dickson, Swiel, Alofa.
Gloucester: Hook; Sharples, Scott, Twelvetrees, May; Burns, Laidlaw; McAllister, Hibbard, Hohneck, Savage, Galarza, Moriarty, Rowan, G Evans.
Replacements: Matu’u, Y. Thomas, Ma’afu, Thrush, Kvesic, Heinz, Symons, Purdy.
Referee: JP Doyle.