Two tries from the Quins front row, one either side of half time, were the decisive contributions as they turned a narrow deficit into a handy lead and Gloucester were chasing the game from that moment on.
Gloucester will be disappointed as their back line looked to be dangerous with Tim Molenaar, Jonny May and Henry Trinder all making scything breaks and May scored the try of the encounter in the second half.
Ultimately, though, it was ill discipline that decided matters as Gloucester fell foul of the referee on just too many occasions which afforded Clegg the opportunity to win the game.
The snow had thankfully ceased by the time this game kicked off but it was still pretty bracing at 3pm.
Gloucester's backline looked lively in the opening stages with a Tim Taylor chip causing problems and a Jonny May kick and chase only halted by the ball rolling into touch near the Quins line.
However, a loose tap from the lineout rolled into the Quins in goal area and prop Yann Thomas pounced for the opening score.
The visitors tried to respond quickly following a break from lock Peter Browne but what looked to be a perfect cross kick from Rory Clegg was called back as the catcher, number eight Chris York, was offside.
Gloucester's pack were enjoying themselves and a strong driving maul almost produced the second try until Quins pulled it down illegally but the visitors escaped as they defended the next lineout resolutely.
Controversy then erupted as a quickly taken tap penalty by Karl Dickson caught Gloucester napping but winger Miles Mantella seemed to fail to ground the ball before being tackled over the dead ball line only for the officials to award the score. Rory Clegg converted for 5-7 after 19 minutes.
Tim Molenaar lifted the crowd with a powerful burst from his own line, breaking tackles on his way to the halfway line only to run out of support.
Tom Voyce then sliced into the Quins 22 after he took a neat inside pass but his offload found a defender when a try looked on the cards.
Henry Trinder was the next to break through and this time Gloucester remained patient, maintaining possession before Alasdair Strokosch put Jonny May in for a try and a 10-7 lead only for a Clegg penalty to level matters just minutes later.
A couple of defensive lapses had Gloucester under pressure as half time approached but Tim Taylor nudged his side into a 13-10 lead on 40 minutes.
However, Quins burrowed over for a try deep into first half injury time with prop Rob Buchanan awarded the score as the visitors took a 15-13 lead into the break.
Tim Taylor was withdrawn at half time so Ryan Mills took over kicking duties and duly nudged Gloucester back into the lead with a penalty as Quins blocked chasers from the kick off only for hooker Chris Brooker to put the visitors back in front with a score from a catch and drive.
Clegg almost battled his way to the line for a fourth try but added a penalty to extend the lead to 16-23 and Gloucester were reduced to 14 men as Matt Betty saw yellow for not rolling away.
The crowd was by now growing exasperated at the lack of refereeing decisions going their way and a not straight line call against Quins drew ironic cheers.
However, referee Harding's next contribution was to allow an extraordinarily long advantage for Quins only to come back for a penalty which Clegg converted for 16-26 after 61 minutes.
With the game slipping away, Gloucester were growing increasingly frustrated as they struggled to get any meaningful possession.
However, Jonny May gave hope as he broke away from his 22, kicked ahead and won the chase for the touchdown as he outstripped all the cover. Mills converted for 23-26 after 73 minutes.
Clegg's fourth penalty though seemed to shut the door for good two minutes later though as the referee's whistle continued to haunt Gloucester and Quins took a 23-29 lead.
To their credit, Gloucester carried on battling and took the game to Quins in the final few minutes. May continued to threaten but time just ran out on the home side and the visitors hung on.