The Bees recovered from a goalkeeping error and David Raya's own goal inside three minutes to climb back into the top two and close the gap to leaders Norwich to a point with a game in hand.
Middlesbrough, who missed out on an opportunity to climb into the top six, had their chances too but Raya was in the mood to make amends with a string of fine saves to leave the hosts frustrated.
Neil Warnock was well aware of the Brentford threat, but the Middlesbrough boss wanted a victory of his own to climb into the top six and handed deadline day signing Neeskens Kebano his first start following his arrival on loan from Fulham.
Kebano and the impressive Yannick Bolasie were soon involved to push Middlesbrough on, earning a couple of early corners.
It was from the second of those that Middlesbrough took the lead. Darnell Fisher's delivery was missed by Raya, the ball bounced off Ethan Pinnock and it clipped the goalkeeper's leg and bounced into the net.
It was the perfect start for the home side, although Brentford were frustrated to have a penalty appeal waved away almost immediately after when Henrik Dalsgaard went through and down in the area.
Ghoddos also had a free-kick parried away by Bettinelli after Sergi Canos was brought down by Fisher right on the edge of the area moments before the equaliser.
After Middlesbrough's complaints of some strong challenges, Brentford turned defence into attack quickly. Dalsgaard's long ball was chested into the path of Fosu by Toney, who ran into the area and was picked out to find the empty net.
Raya continued in that form after the break. He made a point-blank save from Assombalonga again with his left leg and then was just as impressive to deny Janelt from scoring a second own goal of the game.
And with the hour approaching Janelt put Brentford ahead, firing in from outside the area after Toney nodded down Mads Bech Sorensen's long ball.
It was three six minutes later as McNair's slip on the wet surface proved costly on halfway, allowing Jensen to run through, round Bettinelli and find the empty net.
And then, after Raya had denied Saville again, the points were well and truly wrapped up when Toney nodded in his second late on after Rico Henry had struck the bar.