Following a totally one-sided first half Harlequins led 21-6. It should have been far more and a huge defeat for the Welsh seemed likely.
However, Welsh played with great spirit in the second half to reduce the arrears to 24-19 and a remarkable comeback was on the cards before the visitors steadied the ship to run out narrow winners.
Quins signalled their attacking intentions from the start as Ollie Lindsay-Hague fielded the kick-off deep inside his own 22 before setting off a sweeping movement which took the visitors into the home 22. George Lowe and Nick Evans both made vital contributions to the movement but an over-ambitious pass from Danny Care prevented Quins from opening the scoring.
The visitors continued to dominate but missed another chance when Evans was wide with a straightforward penalty attempt but with 15 minutes gone they took the lead with an individual try from Care. The scrum-half brushed aside some very weak Welsh tackling to run 15 metres for the score, which Evans converted.
The visitors soon extended their lead with a second try as Sam Smith did the spadework with a weaving run to create the score for Lowe, which Evans again converted. Welsh were dealt another blow when lock Kirill Kulemin was shown a yellow card for a high tackle on Evans but got on the scoreboard when Gordon Ross kicked a penalty.
Kulemin returned but only in time to see his side concede a third try when Chris Robshaw barged over from close range. Evans converted but a second penalty from Ross made it 21-6 to the visitors at half-time.
The hosts should have scored but number eight Adam Balding chose to drive for the line instead of passing and was held up by the combined efforts of Evans and Tom Guest. Welsh declined two kickable penalties in favour of more attacking options but when awarded two more, Ross made no mistake with both kicks for a 21-12 scoreline.
The Quins were shaken but their nerves were calmed when Evans was successful with a penalty as Welsh committed another offence at a scrum. Back came the hosts to collect their first try when Nick Scott cleverly dummied over for the score, which Ross converted to reduce the gap to only five points.
Quins made the game safe with their bonus-point try, as Evans finished off some neat inter-passing with the outside-half converting for a match tally of 16 points. Ed Jackson's interception try - converted by Ross - brought Welsh back within an unconverted try, but the visitors held on in a frenetic finish which also featured yellow cards for Quins lock George Robson and Welsh prop James Tideswell.