Shandon Baptiste and Sergi Canos had turned the game on its head after Tyler Roberts had opened the scoring.
Raphinha’s stoppage-time penalty clinched a 1-0 win against Crystal Palace on Tuesday night and Bamford sparked similar scenes of jubilation at Elland Road with another last-gasp effort.
Leeds were dealt an early blow when skipper Liam Cooper hobbled off in the 13th minute holding his hamstring after an awkward fall.
Home boss Marcelo Bielsa switched Junior Firpo into central defence and sent on Jack Harrison to slot in at left-back.
Leeds had lived dangerously on several occasions prior to Cooper’s withdrawal without conceding any clear-cut chances, but began to make headway themselves soon after and took the lead with their first effort on goal in the 27th minute.
Raphinha popped up on the left and, after his initial cross was headed straight back at him by former Leeds defender Pontus Jansson, the Brazilian sent in another ball, this time low, and Roberts slid in to turn home his first goal since the penultimate game of last season.
It was Roberts’ first goal at Elland Road since July 2020 and it appeared to give him an extra half yard.
He fired in a fierce drive at the end of another sweeping Leeds attack, which Brentford goalkeeper Alvaro Fernandez tipped over, and fizzed a dangerous ball in across the face of goal.
Kalvin Phillips lashed a shot over the crossbar as Leeds continued to push the visitors back and the same pattern resumed at the start of the second half.
Fernandez’s one-handed save kept out Luke Ayling’s header following Raphinha’s excellent free-kick but, soon after, Leeds found themselves pegged back.
Rico Henry wriggled free on the left and, when Canos’ cross was deflected to Baptiste, the Brentford forward found the bottom corner with a neat finish.
Leeds had another injury setback straight after as Phillips was forced to withdraw - he was replaced by Mateusz Klich - and then the visitors turned the game on its head in the 61st minute.
Bryan Mbeumo’s deft pass inside the box wrong-footed the home defence and Canos pounced to unleash an unstoppable shot into the roof of the net.
Leeds had been in complete control and all of a sudden were floundering.
Bamford made his first appearance since mid-September off the bench and the hosts began to reassert themselves.
Stuart Dallas’ curling effort was saved by Fernandez, who then held Roberts’ long-range shot, but Bamford rescued Leeds at the death.
Raphinha’s corner was flicked on by Ayling and Bamford forced in the equaliser, off the underside of the crossbar, with his knee.
Additional reporting from PA