Gillingham skipper Michael Flynn produced a rare moment of quality in a dull game to hand his side a vital three points against injury-hit Crewe.
With the game seemingly heading towards a goalless draw, Flynn let fly from distance in the 71st minute and the ball found the far corner of Ben Williams' net.
Crewe manager Dario Gradi was without his first-choice front pairing of Luke Varney and Nicky Maynard - ruled out through injury - so turned to Rodney Jack and Michael Higdon to lead his side's attack.
But it was Gillingham's striker Gary Mulligan who forced the first chance of note when he turned smartly in the area and forced Williams to tip the ball behind.
Ten minutes later Crewe had a great chance to break the deadlock but Higdon blazed over from six yards after latching on to Julien Baudet's flick from a Neil Cox free-kick.
Moments later, Cox brought a wonderful save out of Romain Larrieu with a fizzing drive from 20 yards that was heading for the bottom corner until the French keeper intervened.
And Ronnie Jepson's men survived a further scare a minute before the interval when Ryan Lowe flicked the ball through to Jack but the veteran striker shot straight at Larrieu.
The game continued to disappoint after half-time, although Higdon came close shortly after the interval when the impressive Lowe squeezed the ball through the defence but the burly striker's volley found the roof of the net.
But in the 65th minute Gillingham sounded a warning call when Andrew Crofts latched on to Nicky Southall's cross but the Welshman failed to control the ball and the chance went begging.
That miss was forgotten several minutes later when Flynn picked the ball up midway inside the Crewe half and found the far corner of the net with a powerful drive from 25 yards.
Crewe sent on Shaun Miller for Jack shortly after and the youngster almost snatched a dream equaliser when his 80th minute drive deflected off defender Leon Johnson, forcing Larrieu to tip over his bar at full stretch.
But Gillingham held on strongly to secure the three points that takes them closer to League One safety.