Full-back Mike Brown, released from the England training squad for the weekend, scored their first try with stand-in players Matt Hopper and Sam Smith also touching down.
Fly-half Nick Evans, back after an ankle injury, provided an instant return on the new three-year contract he signed earlier in the week by kicking 13 points for Quins, who were without England players Chris Robshaw, Danny Care, Ugo Monye and Joe Marler.
Evans' opposite number Freddie Burns kept fourth-placed Gloucester in contention with six penalties from six attempts before converting a late try by centre Billy Twelvetrees which salvaged a losing bonus point.
But defeat meant they lost their record as the only Premiership side unbeaten away from home this season.
Evans marked his return by kicking his side ahead with a sixth-minute penalty but Burns cancelled it out four minutes later after the Quins scrum was penalised.
Gloucester had made a lively start but the home side scored the first try.
Evans found touch with a penalty from just inside the Gloucester half and hooker Joe Gray's long throw released Maurie Fa'asavalau off the tail of the lineout.
The flanker was hauled down short of the line but Quins quickly moved the ball out wide, where Evans and right-wing Tom Williams combined to find Brown who squeezed over in the left corner and Evans converted from the touchline.
Burns reduced the arrears to four points with his second penalty four minutes later and then cut the deficit to a single point when the home scrum transgressed again.
Former England captain Mike Tindall showed a neat sidestep behind his own line and clever pass to get Gloucester out of trouble when they come under pressure behind their scrum.
Tindall was also prominent in the next attack which resulted in Burns kicking the visitors 12-10 ahead with his fourth penalty after 34 minutes.
But Harlequins showed just why they are the reigning Premiership champions by responding with two opportunist tries as half-time approached.
Dickson, deputising with Care away on England duty, caught Gloucester off guard with a quickly-taken tap penalty and Williams was there again to supply the final pass and send Hopper, who has replaced the injured George Lowe in recent weeks, over near the right-hand corner flag but this time Evans drifted his conversion kick wide.
Worse was to come for Gloucester as James Simpson-Daniel's pass was intercepted on the halfway line by Smith - Monye's replacement - who showed a clean pair of heels as he raced half the length of the pitch to touch down and leave Evans a straightforward conversion.
Burns landed his fifth penalty in the 45th minute but, a minute later, Gloucester were reduced to 14 men when right-wing Shane Monahan was yellow-carded for a dangerous tackle on the airborne Brown as the full-back fielded a high kick.
Evans missed a 57th-minute penalty for Harlequins but made amends, from 40 metres, three minutes later before Burns landed his sixth in the 62nd minute.
Evans landed his third penalty seven minutes from time.
England No 8 Ben Morgan, who had just returned from seven minutes off the field having treatment to a gashed head, became the second visitor to be sin-binned for illegally disrupting a Quins attack as they pressed for a fourth try.
Harlequins chose scrums over penalty shots three times but offended themselves and 14-man Gloucester launched a counter-attack which produced a last-ditch try for Twelvetrees, converted by Burns, to grab their consolation point.
Gilbert has released a new line of rugby cleats. The Gilbert Virtuo 8S is part of the exciting new product. Check it out.
The entire All Blacks apparel line has been updated for 2013/14. Check out the New Zealand All Blacks polo.
The Nike Tiempo is a solid rugby cleat and one of few styles still made from full-grain natural leather.
The Gilbert Blitz 8S rugby cleat is a great cleat at a great price of $69.99. Get a new pair of cleats today.
A cool looking all black rugby cleat with the high performance adidas is known for. Get in the Gear!
Wear the crest of the British and Irish Lions on your t-shirt. A great look for the summer.
The All Blacks Performance t-shirt is black with hints of blue from the training jersey. Very Cool.
The New Zealand All Blacks training jersey for 2013/14. Get in the Gear!
The USA Rugby Pro Alternate rugby jersey is perfect for any fan of the Eagles. Get yours to wear during the summer Test matches.
The NEW All Blacks 2013/14 jersey has arrived at World Rugby Shop. Dare to wear the colors of the All Blacks.