Jonathan Douglas headed home a stoppage time winner as Brentford made it eight wins in nine Sky Bet League One matches.
It looked for a long time as if Oldham Athletic would leave Griffin Park with a share of the spoils in a 0-0 draw and in many respects they would have deserved them.
But Douglas came up with the winner, his first goal of the season, to turn one point in to three at the death.
After an even start, where both teams tried to attack without creating a great deal in the way of clear cut chances, Brentford grabbed the upper hand.
New Brentford Manager Mark Warburton stuck with the 4-3-3 system that had served his predecessor Uwe Rösler well in recent weeks and it gave The Bees a numerical advantage in midfield.
When Adam Forshaw, Douglas and George Saville were able to rotate the ball quickly in the centre of the field, and bring the full backs in to play, Brentford looked likely to create.
Oldham often had to resort to foul means to prevent Brentford moving the ball around the field quickly – James Wesolowski committed at least five fouls in the first 25 minutes before he was cautioned by referee Carl Berry – and the game was stop-start as a result, especially early on.
But Brentford soon got in to their stride and were playing the better attacking football.
Goalkeeper Mark Oxley saved a Harlee Dean header and then held on to a deflected Will Grigg shot.
The Bees could have gone ahead when an Alan McCormack corner was nodded down by Douglas but Clayton Donaldson could only divert it over.
Oldham were defending very deep, leaving no space for Donaldson or Kadeem Harris to run in behind, there were often 21 players in the visitors’ half of the field as Brentford tried to pass their way through.
The visitors did, however, get bodies forward when they had attacking possession and they should have scored from one such chance.
A Brentford attack broke down and McCormack was robbed in the centre of the field, substitute Carl Winchester – who had only been on the field for a matter of seconds – broke forward with only Tony Craig between him and the Brentford goal and four team mates in support.
Winchester just kept running, failed to find the right pass and came up with a shot that Craig blocked; the defender also blocked the follow-up from Genseric Kusunga.
Brentford then broke and Donaldson fired over on the turn from the edge of the penalty area.
The closest The Bees came to a first half goal was when Saville released Forshaw on the left, his reverse pass found Jake Bidwell and his low cross was turned inches wide by Grigg.
The visitors probably ended the first half in the ascendency.
Korey Smith shot well over before Mike Petrasso’s effort from a half cleared cross was blocked by McCormack, the wide man then fired the loose ball wide.
Danny Philliskirk then shot in to the side netting in the dying stages of the first period.
The striker also had a deflected effort saved early in the second while Jonson Clarke-Harris curled a free kick wide.
The start of the second half was even, Brentford probably had more of the ball but Oldham held their resolute defensive line and made life difficult for The Bees.
Brentford’s early chances in the second period all came when Dean met McCormack set pieces from the right.
Two were headed over and one deflected and saved as Oldham kept The Bees out.
The introduction of Sam Saunders in the hour mark gave Brentford a different attacking option and The Bees started to take control again.
Douglas was unable to convert one cross, taking it away from Donaldson arriving late, and when Saunders broke and exchanged passes with Forshaw, hit low shot looked set for the net before Kusunga blocked.
Oxley had to tip a header from his own defender, Jonathan Grounds, over the bar and Bidwell fired over as time ticked down.
Oldham were largely playing on the break, but doing it will.
Clarke-Harris shot wide when a Forshaw slip let him in and McCormack had to block a low Petrasso shot.
They came close to winning it late on when a Smith free kick deflected wide and, from the resulting corner, Grounds met Winchester’s corner only to see McCormack block on the line.
But the crucial goal came at the other end.
Saunders cut in from the right and delivered a left foot cross to the far post, Douglas got above the defence to power a header home and give The Bees the points.
Brentford: Button; McCormack, Dean, Craig, Bidwell; Forshaw, Douglas, Saville (sub El Alagui 80 mins); Donaldson, Grigg (sub Trotta 66 mins), Harris (sub Saunders 60 mins)
Subs (not used): Lee, Logan, O’Connor, Reeves, El Alagui
Bookings: Dean (six mins) (sixth of season), McCormack (84 mins) (third of season), Douglas (85 mins) (second of season)
Oldham Athletic: Oxley; Kusunga, Tarkowski, Grounds, Plummer; Petrasso, Smith, Wesolowski, Mellor (sub Winchester 27 mins (sub Schmeltz 88 mins)); Philliskirk, Clarke-Harris (sub Rooney 70 mins)
Subs (not used): Rachubka, Brown, Rodgers, Lanzoni
Bookings: Wesolowski (25 mins), Plummer (68 mins)
Attendance: 6,594 (421 away fans)
By Chris Wickham