Cardiff Blues ended their LV= Cup campaign with some pride restored by gaining their first win in a high-scoring thriller over Harlequins.
Chris York and Seb Stegmann tries gave Quins the lead, but Blues stormed back as Tom James, twice, and Luke Hamilton crossed for a 24-14 half-time lead.
Wing James added two more tries after the break, while lock Macauley Cook was driven over for a sixth Blues score.
But Sam Smith's try and Ross Chisholm's brace for Quins ensured a tight finish.
Cardiff Blues: Ben Blair; Richard Mustoe; Gavin Evans, Gavin Henson; Tom James; Ceri Sweeney, Lewis Jones; John Yapp, T Rhys Thomas (c), Scott Andrews, Cory Hill, Macauley Cook, Maama Molitika, Josh Navidi, Luke Hamilton.
Replacements: Ryan Tyrell for Hamilton (33), Nathan Trevett for Andrews (65), Sam Hobbs for Yapp (65), Paul Tito for Hill (53), Xavier Rush for Navidi (29), Sion Hopkins for L. Jones (71), Gareth Davies for Sweeney (73), Casey Laulala for Henson (60).
Harlequins: Ross Chisholm; Seb Stegmann, George Lowe, Tom Casson, Sam Smith; Rory Clegg, Karl Dickson; Nic Mayhew, Rob Buchanan, Tim Fairbrother, Tomas Vallejos, Pete Browne, Chris York, Will Skinner (capt), Tom Guest.
Replacements: Darryl Marfo for Mayhew (68), Mark Lambert, Will Collier for Fairbrother (55), Charlie Matthews for Skinner (60), Joe Trayfoot for Guest (55), Richard Bolt for Dickson (51), Benjamin Urdapilleta for Lowe (31), Ollie Lindsay-Hague for Casson (60).
Referee: James Jones (WRU).