The Bees grabbed the lead after only six minutes when midfielder Jay Tabb swept home from ten yard out following a corner by Paul Brooker.
But after that, it had to be a backs to the wall display for Martin Allen's men, who were put to the sword by the marauding U's.
The Essex side had already wasted several chances before their leading scorer Chris Iwelumo brought them on level terms in the 31st minute.
Karl Duguid delivered the perfect cross from the left flank for Iwelumo to head home from six yards out. It was his 18th goal of the season.
There looked to be only one winner after that, but a tiring Brentford hung on grimly to retain second spot in League One.
Mark Yeates gave Brentford's defence a torrid time down the wing and he also struck the bar with a cross-cum-shot, while Bees keeper Stuart Nelson saved well from long-range shots by substitute Billy Clarke and Kevin Watson in the second half.
And when Nelson was beaten he had his defenders to thank for some goal-line clearances. In fact Michael Turner, who had an excellent game at the back, saved the day with clearances on no fewer than three occasions.
Turner's best effort was in hooking away an overhead kick from Tony Thorpe which looked a certain goal.
Brentford were just relived to hold on and so therefore preserve the three-point gap between themselves and fourth-placed Colchester.
Phil Parkinson's men are now unbeaten in four matches, but they have drawn their last three. To stand any chance of claiming the second automatic promotion place themselves behind Essex rivals Southend they will have to regain their scoring touch.
Next weekend Colchester face another key match at improving Nottingham Forest.