City made it eight straight wins thanks to a grandstand finish, as defender Louis Carey celebrated his 350th game for them.
The right-back though had little chance to relax against Brentford's lively top scorer Stephen Hunt.
Hunt's nagging probes on the left and the experience of Tony Rougier on the right of midfield gave the Bees their best attacking options.
Collectively though the young side struggled to match the drive of a team on a roll.
"There is a belief in the camp that we are going to beat every side we meet," said Carey, whose career has seen him play for six City managers since his debut in 1995.
But it was not an easy win, even though City gave themselves the perfect start.
With only four minutes gone Aaron Brown was allowed the first of many free runs down the left flank.
Lee Miller shrugged off a challenge to meet the cross and his sharp downward header ended a personal goal drought stretching back eight games.
The points should then have been wrapped up inside the next 20 minutes.
Visiting keeper Alan Julian, with no one within 30 yards of him handled outside the box for Brian Tinnion to curl a free-kick just over the bar.
Then Tinnion set up Marc Goodfellow with a neat chip. It left the youngster one-on-one with Julian, but his lob fell wide of the target.
Brentford gave the distinct impression of a side struggling to hold on, but it was very different in the second half.
Their back four tightened up, City were constantly straying offside and slowly the momentum switched Brentford's way.
Suddenly, with less than 20 minutes left, they found a breakthrough, Eddie Hutchinson darting past static defenders to knock in Michael Dobson's free-kick.
But City clinched all three points in the dying minutes.
A goalmouth scramble, in which Julian appeared to be impeded, ended with City's acting captain Matthew Hill putting them back in front with a close header.
Then, in time added on, substitute Leroy Lita finally wrapped up the win as he did at Brentford in December with a spectacular goal.