Latics twice fell behind in the first half as Donnelly’s double was cancelled out by strikes from Michael Higdon and Dominic Poleon.
Higdon grabbed his second of the game, and third in three games for Latics to put them ahead but minutes later, substitute Jake Hessenthaler equalised to earn a point for high-flying Gillingham.
David Dunn handed debuts to Burnley duo Danny Lafferty and Cameron Dummigan in his fourth game in charge of the club.
Both sides started the game with their fair share of possession but it was the home side that took the lead on eight minutes.
A give and go saw Gills full back Brennan Dickenson behind Dummigan and he squared the ball into the centre where Donnelly was placed and he slid the Gills ahead.
Two minutes later, the Swansea City loanee could have doubled their lead but dragged his shot wide from the edge of the box.
Latics needed a response and almost hit back on 18 minutes but Higdon’s volley sailed just over the crossbar.
That provoked Athletic into life and they enjoyed a dominant spell of possession.
Daniel Lafferty’s cross tested the Gills defence whilst Dummigan got forward with every attack.
Just before the half hour mark, Latics were level through Sheffield United loanee Higdon.
Danny Philliskirk kept the ball alive inside the penalty box from a corner and he laid the ball back for Higdon to strike and it deflected past Stuart Nelson to equalise for Latics.
From the restart, Athletic earned themselves a corner as they looked to capitalise on their momentum.
However, that momentum was dashed two minutes later as Gillingham regained their lead.
Latics cleared Dickenson’s initial cross into the box but the danger was not cleared and Donnelly headed home at the back post to score his second of the afternoon.
However, Latics did not let that goal affect them and three minutes later they pulled themselves level for the second time in the game.
Loanee Higdon placed the ball into the path of Poleon and he showed good composure inside the penalty box to dink the ball over the onrushing Nelson to equalise.
In what turned out to be an exciting opening 45 minutes, Latics went into the half time break all square.
Dunn’s side started the second half strongly with Higdon proving the focal point of attack.
His pairing with Poleon in attack was proving to be a handful and they combined for Latics to take the lead on 55 minutes, and what a goal it was.
Poleon picked up the ball 30 yards from goal, crossed early to Higdon and on the volley, he planted the ball into the bottom corner giving Nelson no chance in the Gills goal.
However, that lead was to only last two minutes as the Gills hit back instantly through substitute Hessenthaler.
The ball was not cleared and Hessenthaler struck from 25 yards, curling it into the top corner past David Cornell to bring Gillingham back level.
It turned into an end-to-end affair with both sides going for the winner.
After the hour mark, Poleon broke down the middle, taking the ball past two men before being felled on the edge of the box but the refereee waved away the foul.
Gillingham’s Bradley Dack struck wide minutes later before they brought on Cody McDonald in attack.
Lee Croft replaced Swansea loanee Jay Fulton on 70 minutes and five minutes later he received a booking for a late challenge on a Gillingham man.
Both sides put their all into this pulsating tie and with less than 10 minutes of the game remaining Lafferty struck wide from the right hand side.
Half chances followed as Dummigan’s cross was just too close to the goalkeeper whilst at the other end Dack struck straight at the goalkeeper from the edge of the box.
In the final minutes of the game, Latics, who were throwing everything forward in a bid to get the winner, almost got a goal.
Philliskirk picked out Higdon in acres of space in the box but the striker just hesitated as he tried to feed the onrushing Mike Jones.
And in the final minute of the game, Poleon’s met a Dummigan cross but his looping header fell on top of the crossbar.
Gillingham: Nelson, Morris, Egan, Ehmer, Dickenson, Wright (Osadebe 78’), Loft (Hessenthaler 46’), Houghton, Dack, Donnelly, Norris (McDonald 68’).
Subs not used: Morris, Williamson, McGlashen, Lennon.
Oldham Athletic: Cornell, Dummigan, Burn, Wilson, Lafferty, Kelly, Jones, Fulton (Croft 72’), Philliskirk, Poleon, Higdon.
Subs not used: Coleman, Eckersley, Brown, Dieng, Winchester, Yeates.
Goals: Gillingham (Donnelly 8’, 33’, Hessenthaler 57’) 3-3 Oldham Athletic (Higdon 28’, 55’ Poleon 36’)
Attendance: 6,157 (181 visiting supporters)