The lead exchanged hands on several occasions before Harlequins fly-half Nick Evans missed a last-minute drop-goal to win the game for the hosts.
A crowd of more than 70,000 enjoyed a feast of points and four tries before half-time as Gloucester led 17-15.
Quins' Ross Chisholm and Gloucester's Harry Trinder both scored twice, while Rob Cook grabbed the pick of the tries.
Both sides go away with a bonus point but neither were able to get the decisive score on a day which saw England captain Chris Robshaw return to Twickenham for the first time since his team's disappointing World Cup campaign came to a premature end.
In a side-plot to the main event, England winger Jonny May limped off for Gloucester in the second half with an apparent knee injury.
Jeremy Thrush scored the opening try for the visitors after seven minutes before Gloucester open-side flanker Matt Kvesic, who produced a man-of-the-match performance, played a pivotal role in his side's second try, scored by fly-half James Hook.
The Wales international then saw his fellow countryman Jamie Roberts inspire a Harlequins comeback on his first Premiership start for the club.
Marland Yarde and Danny Care crossed in the first half for Conor O'Shea's men to put them back in contention.
Trinder extended Gloucester's lead after the break with his first try before four action-filled second-half minutes produced three tries.
Two went Harlequins' way, through Nick Easter and Chisholm, and then Trinder ran in his second, but pulled a hamstring in the process.
Greig Laidlaw's penalty and Cook's dazzling run through the Harlequins defence seemed to make the win safe for Gloucester.
But Evans kicked the home side to within a converted try and replacement Chisholm raced over once more to level it up again.
Evans attempted a last-gasp drop-goal to win it, but his kick drifted just wide to the right.
Harlequins: Brown; Yarde, Lowe, Roberts, Visser; Evans, Care (capt); Marler, Ward, Collier, Horwill, Matthews, Robshaw, Clifford, Easter.
Replacements: Buchanan, Lambert, Sinckler, Merrick, Wallace, Dickson, Botica, Chisholm.
Gloucester: Cook; Sharples, Meakes, Twelvetrees, May; Hook, Laidlaw (capt); McAllister, Hibbard, Afoa, Thrush, Galarza, Kalamafoni, Kvesic, Morgan.
Replacements: Dawidiuk, Murphy, Doran-Jones, Savage, Rowan, Heinz, Burns, Trinder.
For the latest rugby union news follow @bbcrugbyunion on Twitter.

Karen Gell, 50, from Manchester, and Ann Marie Dewhurst, known as Marie, 69, from Preston, perished in the crash on the A69 just before 10:00 BST on Saturday.
It happened on an eastbound stretch of the road between Haydon Bridge and Bardon Mill, Northumbria Police said.
Six people are recovering at home while two others remain in hospital. The road was closed for several hours.
One of those in hospital has critical but stable injuries and the other has serious but not life-threatening injuries, police said.
Harlequins and Gloucester shared 10 tries in an epic 39-39 Premiership draw at Twickenham.
[NEXT_CONCEPT]
Two people who died in a four-vehicle crash have been named by police.