Tries from Luke Northmore and Danny Care on his birthday saw Harlequins battle to victory against Gloucester.
The Premiership champions had been 10-0 behind after a Ruan Ackermann try had given the Cherry and Whites the lead.
But Northmore crossed and Marcus Smith converted and kicked a penalty to level the scores at the interval.
Care went over after concerted pressure from Quins in the second half and they held on despite Santiago Socino's late score for the hosts.
Quins stay third after backing up their victory against Northampton in the Big Game at Twickenham six days earlier, while Gloucester remain fourth despite coming away with a losing bonus point.
After a scoreless opening quarter, the sides went into the interval level as they traded a converted try and a penalty each.
Gloucester managed to keep the champions at bay for more than half an hour, but missed the chance to build more of a lead when prop Val Rapava Ruskin knocked on just short of the try-line as he tried to finish what would have been a fantastic end-to-end team score.
Number eight Ackermann did power over soon after a neat line-out move following an earlier yellow card for Tom Lawday and Hastings' conversion put them 10-0 ahead.
But Quins capitalised on their first visits to the Gloucester 22, firstly with a Smith penalty and then with Northmore's try from Jack Kenningham's pass to level it up.
Northmore ended the half in the sin-bin for a deliberate knock-on that denied pacy Louis Rees-Zammit a line break for a possible try.
Neither side could forge ahead in the third quarter despite Harlequins dominating territory, and Smith saw a penalty strike the left upright shortly after the hour.
Dino Lamb was also forced into touch in the corner as he tried to finish Hugh Tizard's pass, but Care went over for their second try a moment later as he peeled away from the back of a scrum on his own to score on his 35th birthday.
Smith then put them more than a converted score ahead with his second successful penalty and that would ultimately prove to be the difference as replacement hooker Socino's converted score from a rolling maul was not enough to earn a draw for Gloucester.
Harlequins' next fixture will see them host Exeter in a repeat of last season's Premiership final on Saturday while Gloucester travel to Saracens on the same afternoon.
Gloucester head coach George Skivington told BBC Radio Gloucestershire:
"The positives are we defended the best-attacking team in the league really well for most of the game and we created enough in the first half to put them away a few times.
"But in the end, they showed us how to manage that second half really well.
"We probably weren't good enough with our ball retention and a couple of penalties in the second half and Quins are really good at applying pressure.
"In the end, it's really disappointing, as if we'd taken a few more opportunities in the first half, we could've won it.
"We'll learn and get better as these games when you're playing top four teams, you're only going to get a few chances and we've really got to work hard to take those when they present themselves."
Harlequins senior coach Tabai Matson:
"To get a result here is phenomenal, but to do it with a couple of yellow cards in the first half showed real grit and determination.
"We had the territory and possession, and it was only a matter of time before we got the scoreboard ticking over. It took a lot, and to sneak away by just three points is a great result for us.
"To play with 14 men for 20 minutes is pretty significant. It's really tough here, but to do it with 14 for a period shows how well we adapted."
Gloucester: Evans; Rees-Zammit, Harris, Twelvetrees, Thorley; Hastings, Meehan; Rapava-Ruskin, Singleton, Balmain, Clarke, Alemanno, Reid, Ludlow (capt), Ackermann.
Replacements: Socino, Ford-Robinson, Gotovtsev, Davidson, Clement, Chapman, Seabrook, Moyle.
Harlequins: Green; Lynagh, Northmore, Esterhuizen, Marchant; Smith, Care; Garcia Botta, Walker, Collier, Symons, Tizard, Lawday, Kenningham, Dombrandt (capt).
Replacements: Musk, Els, Kerrod, Lamb, Wallace, Gjaltema, Edwards, Jones.
Sin-bin: Lawday (23 mins), Northmore (40 mins).
Referee: Tom Foley (RFU).