Gillingham moved six points clear of the League One relegation zone after winning 2-1 at in-form Bury.
Bradley Dack gave the Gills a 14th-minute lead before Cody McDonald made it 2-0 from just their second effort on target early in the second half.
James Vaughan pulled one back with an overhead kick and Bury struck the woodwork twice in the second half, but the Gills held on to make it two wins from three and leapfrog the hosts.
Bury were on top for most of the contest, with the visitors sitting back after Lee Martin laid off for Dack to fire home on the break.
Vaughan and Jacob Mellis fired off target for the Shakers before Greg Leigh turned a Paul Caddis cross wide.
Tom Beadling, Cameron Burgess and Tom Pope also went close for Bury before the break, yet two minutes after the restart McDonald scored with a free header from Dack's corner.
The Shakers replied with Callum Styles firing wide before Stuart Nelson tipped Mellis' 20-yard strike on to the post.
Vaughan pounced on a loose ball to volley in his 20th goal of the season in the 75th minute before Nelson denied substitutes Ryan Lowe and George Miller.
Miller then headed against a post but Bury's five-match unbeaten run came to an end Vaughan as headed straight at Nelson at the death.