Chris Dickson returned to Crewe and hit a second-half double as Gillingham picked up their second win under Mark Stimson.
The Charlton Athletic striker spent an unproductive one-month loan with the Cheshire side back in August.
But since joining Gillingham he has hit a rich vein of form in front of goal.
The 22-year-old frontman scored his ninth and tenth goals for the Gills as they came from 2-1 down in the second half to record a deserved victory.
Home keeper Ben Williams gifted the opening goal in the eighth minute, when he failed to hold on to a corner. Dickson headed onto the post, but Mark Bentley followed up to head home from close range.
Stuart Thurgood went close to getting the second for the visitors when he shot just wide of the post.
Crewe forced their way back into contention midway through the half and on-loan striker Simon Church's scissor-kick was kicked on to the bar by Simon Royce and Nicky Maynard volleyed the rebound goalwards. Simon King came to the rescue heading off the Gillingham line.
Royce was in inspired form and made good saves from Julien Baudet and Elliott Bennett, but he could do nothing to keep out Maynard's equaliser two minutes before the interval.
The young striker, who was returning from a four-month injury lay-off, volleyed into the far corner.
Gary Roberts blasted Crewe's second from the edge of the box four minutes after the restart, but a debatable penalty on 56 minutes turned the game, when Chris McCready was adjudged to have pushed Dickson.
The young striker sent Williams the wrong way from the penalty spot, then finished with aplomb from the right of the goal with a thunderous half-volley and notched Gillingham's 75th-minute winner.