Erling Haaland scored a vital winner 19 minutes from time as Manchester City eventually broke Brentford's stubborn resistance to close to within a point of the Premier League summit.
What looked set to be a night of frustration at Etihad Stadium for Pep Guardiola's men turned on a moment of huge fortune.
Brentford defender Kristoffer Ajer appeared to have the situation under control when Julian Alvarez played a pass into the visitors' half as City countered.
But as Haaland began the chase, Ajer slipped and could not regain his feet as the Norwegian sped past.
The 23-year-old kept his cool to beat Mark Flekken with a precise shot.