Luton came from behind, took a two goal lead then conceded three second half goals to exit the Johnstone's Paint Trophy.
Two from Paul Furlong and a Matthew Spring penalty had given the Hatters a comfortable half-time lead, but the star of the show was Chris Dickson, who hit a hat-trick to give the game to the Gills.
Dickson, on loan from Charlton, had already given Gillingham the lead in the 16th minute before Furlong equalised and then Luton hit two in a minute to take a half time lead.
Luton got to 74 minutes with that lead intact, but then Dickson pounced on some sloppy defending to score twice before an uncharacteristic blunder from Chris Perry handed them the game.
He was bringing the ball out of defence but turned to pass back to Dean Brill, not noticing that Bentley was standing on the edge of the box. The Gillingham captain gratefully took the ball round the keeper and tucked it into the net to make it 4-3 and Luton had no time to find a way back.
Worse for the Hatters was that Dave Edwards limped off midway through the first half with what looked like a thigh strain.
Luton had to come from behind after they fell to a sweeping move on 16 minutes. Stone fired over a deep cross from the right that Mulligan managed to reach beyond the far post and turn back across goal with Brill stranded at the far post. Chris Dickson stretched and prodded the ball into the empty net from two yards.
But you can't keep Furlong down right now and he equalised on 26 minutes, and then put Luton ahead with his eighth of the season.
First McVeigh put a good through ball in to Furlong, who was strong enough to hold off a challenge and stab the ball under the keeper. He then watched as it rolled slowly into the net to make it 1-1.
That looked likely to be the half time score until the Hatters wrenched control of the game away from Gillingham.
First Furlong grabbed his second two minutes before the break after good work down the left by McVeigh. He whipped a cross over from the left that found Brkovic beyond the far post. Brko looked up and fed the ball into the near post where Furlong running in dinked it delightfully over the onrushing keeper, one bounce inside the far post for his eighth of the season.
The game had hardly restarted when ex-Hatter Duncan Jupp hauled down McVeigh in the box. The referee immediately pointed to the spot and Matthew Spring stepped up.
He took a stutter run up and then lifted the ball into the top corner to the keeper's left, giving Stillie no chance at all even though he guessed the right way.
Gillingham had their chances in the second half. Dickson hit a curling shot from the left into Brill's midriff, Mulligan flicked on a header that scraped the foot of the far post, Jupp fired over from 12 yards out and then Dickson again hit another screamer just wide of the post.
But then Dickson found the breakthrough and grabbed his second to make it 3-2 on 74 minutes when a ball from Mulligan found its way across the box and he lashed it into the net from 10 yards out.
The lively Dickson grabbed his third on 80 minutes when a cross from the left was not dealt with and he stabbed it in on the far post to make it 3-3.
Then came the disaster of the night with Perry's back pass.
After that Luton had no time to get back into it and try to force penalties and they went out of their first competition of the season.
Teams:
Gillingham: Stillie, Jupp, Armstrong, King, Bentley, Mulligan (Nowland 83), Southall, Sodje, Cogan (Graham 63), Dickson, Stone
Subs: Hamilton, Clohessy, Pugh
Bookings: King 60
Luton: Brill, Jackson, Perry, Fojut, Emanuel, McVeigh, Spring, Hutchison (O'Leary 77), Edwards (Brkovic 23), Furlong, Andrew (Talbot 77)
Subs: Goodall, Charles
Bookings: Brkovic 53


















