The Whites, for a second time in five days, required a goal deep in added time in LS11 to secure a positive result on home soil.
Marcelo Bielsa's side caused more chaotic scenes thanks to the returning Bamford, who was handed his first appearance since mid-September due to an ankle injury.
The 28-year-old forward reacted quickest to a flick on from a Raphinha corner to turn the ball home from his knee off the underside of the bar.
The strike came in the fifth minute of injury-time on his comeback and helped move Leeds six points clear of the top flight drop zone.
United's No 9 was introduced from the bench with around 20 minutes to go after the Bees had turned the game on its head in the second half.
Brentford trailed following a Tyler Roberts opener on his 100th Whites match but goals from Shandon Baptiste and Sergi Canos put Thomas Frank's outfit ahead.
Leeds battled back and grabbed a stunning draw just seconds before time expired which caused more wild scenes in the home stands.
Here, we take a look at the best photos of supporters during an up and down afternoon in LS11...