© Getty Images
Gillingham keeper Stuart Nelson was kept busy in the early stages of the match as the hosts dominated the opening half-hour of the tie.
Marcello Trotta looked dangerous at the start of the second half as the home side sought to double their lead, but he saw one effort saved before forcing another just wide.
However, the striker was able to get on the scoresheet with just over 20 minutes left to play as Michael Harriman gave away a penalty, which the Italian was able to convert.
Gillingham got themselves back into contention just three minutes later as McDonald teamed up with Fagan again, and this time managed to find the target, just squeezing his chip past David Button.
Adebayo Akinfenwa twice had the chance to score an equaliser for Gillingham, but headed wide before seeing his cross into the box claimed by Button.