Two goals in the last 15 minutes sent Rochdale back to Greater Manchester with all three points from a wet and windy Griffin Park and dealt a fatal blow to Brentford's play-off push.
Lee Thorpe marked his first return to Griffin Park after his January transfer by heading The Dale in front after coming on as a substitute and the impressive Adam Rundle sealed the win in the dying seconds.
It could have been described as a smash and grab raid as Brentford certainly had the better of openings and dominated possession but the visitors gave a perfect example of how to play away from home, defending deep, breaking at speed and taking their chances when they came.
Brentford will feel they could have got something out of the game but could not find the killer touch in front of goal.
They could have been ahead inside ten minutes when Nathan Elder raced clear of the Rochdale defence and onto a Glenn Poole pass but he blazed wide and the rest of the afternoon followed suit.
Poole shot straight at Tommy Lee in the visitors' goal and then saw a header from an Elder cross pushed out before Alan Connell lofted an effort into Lee's arms when he found space.
Rochdale were making more of their possession, Rene Howe headed a Rundle cross against the post from a tight angle and Adam Le Fondre came close to turning home a swinging Chris Basham corner before Simon Brown was forced into a low save from a fierce Gary Jones shot.
But it was Brentford who were on top, Elder headed a Poole cross wide as half time approached and Alan Bennett almost capitalised when Lee dropped another cross from the Brentford wide man before Ryan Dickson curled a free kick wide.
And it continued after half time, Nathan Stanton blocked well when it looked like Elder would find space to score minutes into the second half, Lee saved well from Poole and Connell miss-hit an effort when well placed.
Lee saved well from a Bennett header, then from a low Poole shot before Connell volleyed narrowly over after an exquisite turn.
The visitors made three substitutions, introducing Thorpe, Ben Muirhead and Chris Dagnall, and they looked more threatening.
Thorpe shot straight at Brown soon after coming on and Rundle fired wide before The Dale edged ahead with 14 minutes left.
A cross from Simon Ramsden travelled from the right touchline into Brentford's box and Thorpe was allowed too much space to arc a header over the stranded Brown and into the far corner.
The goal was very much against the run of play and Brentford continue to press, laying siege to the visitors' goal at times.
Elder had a shot blocked, Wayne Brown shot over and Connell was unable to turn home an Elder nod down as time ticked on.
Dagnall headed wide at the other end but Brentford should have equalised in stoppage time when a long ball caused panic in the Rochdale defence, Connell got a shot off that Lee was able to parry and Elder fired the re-bound over from close range.
And Rundle made Brentford pay when he sealed the win in the 94th minute, firing home at the second attempt after Muirhead had raced clear on the right.
A two-goal defeat may have been a little unjust but Rochdale, who are closing in on the top seven themselves, didn't care.
Brentford: Simon Brown; Pead, Heywood, Bennett, Dickson; Shakes (sub W. Brown 77 mins), Mousinho, O'Connor, Poole; Elder, Connell
Subs (not used): Hamer, Sankofa, Reid, Smith
Rochdale: Lee; Ramsden, Stanton, McArdle, Kennedy; Basham (sub Thorpe 53 mins), Jones, Perkins, Rundle; Howe (sub Dagnall 68 mins), Le Fondre (sub Muirhead 53 mins)
Subs (not used): Button, Holness
Written by Chris Wickham