The scoring started in just the second minute when Zak Vyner fired home from close range.
Midway through the first half, the Bees drew level thanks to a goal from winger Sergi Canos.
Minutes into the second half, Ivan Toney grabbed his 20th league goal of the season after great work from Fosu.
Soon after, Saman Ghoddos grabbed Brentford's third goal of the game and looked to have sealed the win.
However, in the 90th minute, Nakhi Wells grabbed his sixth of the season to set up a nervy finish.
The win extends Brentford's unbeaten league run to 19 games and puts them up to second in the Championship, whilst Bristol City remain in ninth position.
Story of the match
Both sides made changes. The home side brought in Vitaly Janelt for Josh Dasilva, whist the visitors brought in Han-Noah Massengo and Owura Edwards for Tommy Rowe and Wells.
Bristol City took the lead after just two minutes when Zak Vyner lost Ethan Pinnock in the box and got on the end of a brilliant free-kick from Jack Hunt to fire into the top corner from just six yards out.
Brentford's first real chance fell to forward Ghoddos who had his powerful strike deflected and subsequently turned wide by Robins goalkeeper Dan Bentley.
Despite the early goal, neither side created any real clear cut chances in the first 20 minutes with the game lacking any real creativity and tempo.
Brentford pulled level after 26 minutes after great work down the right by Fosu the winger drilled the ball across the six-yard box and was tapped into an empty net by Canos.
After Canos' strike, Brentford looked the more likely to grab the games third goal, but Thomas Frank and his side had to settle for a level game at the break.
Just 20 seconds after the break, Vyner nearly doubled his tally after receiving the ball on the edge of the 18-yard box, he fired towards goal, but his marvellous effort was parried wide by David Raya.
Brentford took a deserved lead after 49 minutes when Fosu again beat Adrian Mariappa and whipped a great ball into the path of Championship top scorer Toney who volleyed the ball into the bottom right corner.
A brilliant run from Canos took him past three Robins defenders and led to a great ball to midfielder Mathias Jensen who dragged a tame shot wide of the upright.
65 minutes in and Brentford grabbed a third. Fosu instrumental again dribbled past Mariappa and slipped the ball into the path of Ghoddos who had a thunderous effort tipped onto the bar by Bentley before firing the rebound into the empty net.
Dean Holden's side had a good spell for the next 10 minutes but were simply unable to test Raya in the Brentford goal.
Centre back Winston Reid came on for Brentford for the final five minutes to make his debut after joining on loan from West Ham United.
Bristol City grabbed a consolation goal after a controversial offside decision saw substitute Wells rounded Raya and finish into an open goal.
Man of the match - Tarique Fosu (Brentford)
Over the last few weeks, Fosu has been simply sensational. The 25-year-old contributed a hat-trick of assists tonight to help his side jump into second position.
After the departure of Said Benrahma, many Bees fans feared the worse for their frontline, however, Fosu has been a more than adequate replacement in the last few weeks.