Gloucester climbed to fifth in the Premiership as they beat leaders Harlequins in an outstanding game.
Charlie Sharples' try and Jonny May's score, added to 11 points from Freddie Burns, were answered by Ross Chisholm's try and eight points from Nick Evans.
After the interval both number 10s exchanged penalties before Akapusi Qera's try put the hosts in control.
But Chisholm raced in from 70 metres, Evans' conversion salvaging Quins a losing bonus point at the death.
After Burns had kicked Gloucester to an early lead James Simpson-Daniel, in his 250th club game, produced a scything break and then turned creator for Sharples' try on 10 minutes.
Burns added the extras to make it 10-0 but Evans soon pulled six points back for Quins with a brace from his boot.
In a game already brimming with entertaining endeavour on both side Gloucester full-back May then produced one of the individual tries of the season.
His side-stepping masterclass was followed by a textbook hand-off that blossomed into a blistering 35m sprint for the line.
Although the conversion was missed, The Shed was in full voice after May's magic and they roared with delight when a second penalty against James Johnston for binding on the arm saw Burns convert from the tee to make it 12-6.
But the visitors bustled up the park and after two driving runs by Ugo Monye, Evans nudged the ball through Gloucester's line and it sat up perfectly for Chisholm to ground.
The New Zealander converted but after Quins were done over again in the scrum Burns landed a third penalty after the half-time whistle to make it 21-13.
Evans and Burns exchanged penalties early in the second half and that quickly developed into a feast of off-loading and running rugby.
Burns failed to capitalise when Johnston was again penalised for poor binding at the scrum but his intelligent break, coupled with Ryan Mills's floated miss-pass, lead to Qera's score on the hour.
Quins got to within five metres of Gloucester's line ended with a turnover and fabulous breakout of defence by Burns.
It sparked a sensational series of line-breaks on both sides with Burns again at the fore and only his wild pass flung out of the back of his hand denied Sharples a second.
With seconds remaining Quins decided to run the ball from their own 22 and when the ball reached Chisholm he showed phenomenal pace to race away from 70m out.
Evans landed the touchline conversion to claim the losing bonus-point with the final kick of a fabulously entertaining game.
Harlequins director of rugby Conor O'Shea was annoyed afterwards that a crucial drive on the Gloucester line in the second half should have been awarded as a penalty and that Qera should have been sin-binned.
Gloucester coach Bryan Redpath:
"There has been a lot of criticism about the Premiership and, in parts, rightly so, over the past months but tonight was good. It was a great advert for the Premiership and excites the crowd.
"But we have won nothing and achieved nothing yet. I don't think that is something to get too excited about. We blew an opportunity to get a winning bonus point.
"James Simpson-Daniel was exceptional. He did hardly anything wrong in the whole game and when you talk about the young kids and what people do and don't do well, you will see that James has a high percentage of things that go well. That comes with experience.
Harlequins director of rugby Conor O'Shea:
"It was a penalty to us. Qera just ripped the ball off the ground, off his feet. It is then a one-score game with 15 minutes to go but that is the way it is.
"Sometimes those go for you and sometimes they go against you. Sometimes it's a sin-bin. It was a straight penalty, if not a yellow card. With minutes to go, it would have been interesting but it knocked the stuffing out of us.
"However, take nothing away from the game. For a neutral, that was great. At the end of the day, they took more chances than we did. We had loads of opportunities and it was two teams who went toe-to-toe."
Gloucester: May, Sharples, Trinder, Tindall, Simpson-Daniel; Burns, R Lawson; Wood, Dawidiuk, Harden; James, Brown; Savage, Qera, Cox.
Replacements: Lewis for R Lawson (28), Mills for Trinder (51), Buxton for James (51), Knight for Harden (67), Deacon for Qera (73), Murphy for Wood (76), Cortese for D. Dawidiuk (76), Voyce for Simpson-Daniel (78).
Harlequins: Chisholm; Williams, Lowe, Turner-Hall, Monye; Evans, Dickson; Marler, Gray, Johnston; Kohn, Vallejos; Guest, Skinner, Easter.
Replacements: Brooker for Gray (29), Care for Dickson (51), Lambert for Monye (55), Fairbrother for Johnston (55), Browne for Kohn (64), Wallace for Guest (64), Hopper for Lowe (68).
Referee: Dave Pearson (RFU).