Peter Richards had a fine game for Gloucester at scrum-half
Harlequins: 21 (16)
Tries: Jones, Keogh
Pens: Mehrtens 3
Gloucester: 31 (6)
Tries: Richards, Azam, Forrester
Cons: Walker 2
Pens: Walker 4
Gloucester mounted a tremendous second-half comeback to condemn newly promoted Harlequins to their second defeat of the season.
Quins opened up a 10-point lead at half-time thanks to 11 points from Andrew Mehrtens and Ceri Jones' try.
But Gloucester stormed back after the break with tries from Peter Richards, Olivier Azam and James Forrester.
And 16 points from the boot of fly-half Willie Walker meant Simon Keogh's late try for Quins was only a consolation.
The win took Gloucester to the top of the Premiership table after two matches.
Neither side established much by way of rhythm early on as possession was surrendered with alarming ease.
Jones scored the opening try of the game in the 28th minute, providing the finishing touch to a lovely move involving Steve So'oialo, Andre Vos and Nicolas Spanghero.
And further kicks from Mehrtens and Walker made it 16-6 at half-time, with Quins in control.
It was a different story after the break though, as Gloucester - inspired by the excellent Richards - attacked at every opportunity.
Andy Hazell was denied only by a brilliant tackle from Keogh, but Richards opened Gloucester's try-scoring account with an excellent individual effort from 45m.
Azam powered over in the corner after 63 minutes, and Forrester made the game safe in the 67th minute when he took advantage of some more sloppy Quins defending down the blindside.
Keogh crossed late on to cut the gap, but Quins had left themselves too much to do.
Quins director of rugby Dean Richards:
"If you look at the stats then you'll see that most people missed tackles.
"Sometimes if you are in an exposed area of the field sometimes it looks worse than players who miss them close in so I'm not going to start pointing fingers.
"There were a couple of tackles where people were just brushed off which is unacceptable. The players who missed those tackles will be kicking themselves."
Gloucester boss Dean Ryan:
"We didn't turn up in the first half.
"We tried to play too much rugby and we probably didn't give enough credit to the side that was facing us.
"It took until half-time to address it, and once we did we played in the right areas and we have some great players to play off the back it."
Harlequins: Williams; Keogh, Luscombe, Abbott, Strettle; Mehrtens, So'oialo; Jones, Hayter, Nebbitt; Spanghero, Miall; Vos, Volley, Easter.
Replacements: Richards, Ross, Evans, Hala'ufia, Care, Jarvis, Duffy.
Gloucester: Morgan; Foster, Keil, Allen, Bailey; Walker, Richards; Wood, Davies, Califano; Bortolami, Brown; Buxton, Hazell, Forrester.
Replacements: Azam, Forster, James, Narraway, Lawson, Mercier, Adams.
Referee: Roy Maybank (Kent)