Goals from Harry Forrester and Marcello Trotta twice gave the Bees the lead, but Uwe Rosler’s side were hauled back thanks to Bury’s only two efforts on goal.
Tom Soares and Nicky Ajose were the Shakers’ heroes with second-half goals out of nothing as Brentford dominated possession, but created little.
Forrester broke the deadlock just after the break, cleverly heading Shaleum Logan’s far-post cross back across goalkeeper Trevor Carson and in.
But the visitors were level just after the hour-mark when Soares beat Logan in a sprint to smash the ball into the roof of the net from the edge of the area.
Trotta edged Brentford in front again two minutes later, coolly side-footing home from a tight angle after Carson had denied Jonathan Douglas and Logan with reflex saves.
But Logan was caught napping from a 76th-minute free-kick, which eventually found its way to Ajose, whose glancing header gave Simon Moore no chance.
Trotta and Douglas both wasted gilt-edged chances to put the game beyond Bury’s reach in the first half, the Italian volleying over after a sweeping five man move.