The Dons, followed to Kent by just 75 faithful fans, led 1-0 as early as the fourth minute and might have been 2-0 up, but for a glaring miss by Damian Francis.
The Gills were out of sorts early in the game and slack marking at the back let in Connolly to score his 18th goal of the season.
Gillingham awarded contract extensions to Chris Hope and Danny Spiller before the game but on the pitch Gillingham let Wimbledon dictate the pace for the game, and were constantly caught out by swift counter-attacks by the Londoners.
Rod Wallace missed Gillingham's best chance, firing over the bar from close range before Gareth Ainsworth and Francis should have extended Wimbledon's lead.
Then former Arsenal defender Moritz Volz saw his long-range effort tipped over the bar by Gills keeper Jason Brown.
Skipper Paul Smith shot wide early in the second half before Gillingham finally got on terms with a 61st minute equaliser by Paul Shaw.
A well-worked short corner move involving Hessenthaler, Simon Osborne and Nicky Southall ended with Shaw scoring his ninth of the season.
Substitute Guy Ipoua, replaced Osborne on 59 minutes and shot wide soon after coming on before Gillingham took the lead for the first time on 77 minutes.
Shaw provided the cross and Wallace headed in from six yards via the far post for his fifth goal in six games to take his tally for the season to nine.
However, four minutes later Wimbledon were level themselves, substitute Patrick Agyemang's strong run down the right ended with a deep cross to the far post where Nigel Reo-Coker had the easy task of shooting into an empty net.
Sixty seconds later though Gillingham were 3-2 up, Wallace swung in a cross from the right and Shaw fired home from inside the six-yard box for his second of the night.
Wimbledon's third came courtesy of a Neil Shipperley penalty as he joined Connolly on 18 for the season.
Assistant referee Mick McCoy flagged for handball against Mark Saunders, after referee Phil Joslin had already signalled for a corner.
Gillingham protested but Shipperley calmly stepped up to beat Brown easily from the spot with three minutes remaining.