England fly-half Marcus Smith kicked a last-gasp penalty to give Harlequins a dramatic 36-33 victory in a 10-try Heineken Champions Cup thriller against Cardiff.
Smith kicked 16 points, inspiring a fightback from 33-19.
His late try was supplemented by scores from Louis Lynagh, Tyrone Green, Luke Northmore and Danny Care.
Cardiff wing Owen Lane scored two tries with James Ratti, Dillon Lewis and Corey Domachowski also crossing.
Smith's brilliance allowed Harlequins to book their place in the Champions Cup last 16 with a third successive win, while Cardiff have suffered a hat-trick of defeats after this heartbreaking loss.
The excellent encounter was played behind closed doors because of Welsh government regulations, although there were people watching legally from the Cardiff Arms Park clubhouse. The regulations will be relaxed next weekend and fans will return.
In December Harlequins overcame a team of Cardiff "misfits" after the Welsh region were caught up in Covid issues during an aborted United Rugby Championship trip to South Africa.
A shadow Cardiff side also lost to Toulouse last month, but the line-up this time was much stronger with 14 internationals in the starting side, number eight Ratti the only exception.
Harlequins, who had also defeated Castres last month, made three changes including the return of wing Lynagh but were without influential South Africa centre Andre Esterhuizen.
Harlequins dominated the opening exchanges and it was a clever Smith cross chip kick from which Lynagh gathered and crossed. Smith converted.
Cardiff retaliated with a smart finish from wing Lane in front of Wales coach Wayne Pivac and his backroom staff ahead of the Six Nations squad announcement next week.
The hosts almost followed this up with a second score following incisive bursts from Rey Lee-Lo and Josh Adams before Ratti powered over.
Cardiff were inspired by Wales scrum-half Tomos Williams and inventive play from lock Seb Davies but Jarrod Evans missed a penalty chance to extend the lead.
Harlequins were hampered by handling errors but relied on their driving lineout and scrummaging superiority against an increasingly ill-disciplined home side.
Moldovan prop Dmitri Arhip was shown a yellow card for collapsing a scrum just before half-time and it proved an expensive sin-binning with 12 points conceded.
Harlequins full-back Green scored after latching on to a cross kick with Cardiff leading 14-12 at half-time.
The visitors almost produced a brilliant try inside the first minute of the second half when Joe Marchant collected another fine Smith kick before the supporting Danny Care sprinted over to score.
The television match official (TMO) picked up Care being offside from the original kick and the try was chalked off.
But there was no saving the home side when former Cardiff Met students Alex Dombrandt and Luke Northmore combined for the centre to canter over.Willis Halaholo of Cardiff and Joe Marchant of Harlequins
Just after Cardiff were restored to a full complement, Harlequins captain Dombrandt was shown a yellow card for a professional foul on his own line.
Cardiff capitalised, with replacement prop Lewis powering over and Evans' conversion restoring the lead.
Lane then scored a second opportunist try on the opposite wing when he latched on to an Amos kick with television replays showing he was onside and had grounded the ball.
The rampant hosts produced a brilliant third try, with some sublime handling rewarded with a try for prop Domachowski as Harlequins shipped 19 points when they had 14 men.
The visitors retaliated with a short-range score from scrum-half Care before more persistent offending from Cardiff saw hooker Kirby Myhill shown a yellow card.
His brother Torin came on after being drafted in from Welsh Premiership side Carmarthen Quins with hookers Liam Belcher, Iestyn Harris, Efan Daniel and Kristian Dacey injured.
Torin Myhill had been in the Arms Park away dressing room for Carmarthen Quins against the Cardiff club side just six days earlier.
It was not the Harlequins power that levelled the scores as Smith danced through the Cardiff defence for a converted try.
With both sides trying to win the game, Rhys Priestland and Adams attempted to run the ball out of defence and were penalised. This allowed Smith to step up and slot over the match-winning penalty.
Cardiff: Amos; Lane, Lee-Lo, Halaholo, Adams; J Evans, T Williams; Carre, K Myhill, Arhip, Turnbull (capt), S Davies, Lewis-Hughes, Jenkins, Ratti.
Replacements: T Myhill, Domachowski, Lewis, Thornton, Boyde, L Williams, Priestland, B Thomas.
Harlequins: Green; Lynagh, Marchant, Northmore, Murley, Smith, Care; Marler, Walker, Collier, Symons, Lamb, Taulani, Lawday, Dombrandt (capt).
Replacements: Riley, Botta, Kerrod, Tizard, White, Stafford, Edwards, Jones.Match officials
Referee: Tual Trainini (France)
Assistant referees: Benoit Rousselet & Cedric Marchat (France)
TMO: Eric Gauzins (France)