Until that point City had been guilty of not taking their chances as Sterling fired over on the volley from Phil Foden's perfect cross and Aymeric Laporte side-footed inches wide from Ruben Dias' knockdown.
The hosts never looked in danger of conceding as they registered a 14th clean sheet in 24 league games this season.
However, Guardiola's celebrations when the second goal finally arrived 20 minutes from time told the story of nerves beginning to build around the Etihad that their dominance was not showing on the scoreboard.
Brentford's determination to play out from the back caught them out as David Raya passed straight to Sterling.
The Spanish goalkeeper redeemed himself by saving a one-on-one with the England international, but the ball fell kindly for Kevin De Bruyne to roll in his eighth goal of the season.
"They are so difficult to attack," said Guardiola. "You have to be patient, make no mistakes and in the end we got the result."
City have registered 100 and 98 points in two of their previous title-winning seasons under Guardiola and are setting a similar pace with 60 points already in the bag.
"Everyone is tough competition, but it is impressive at this stage to have 60 points," added Guardiola. "We have done incredibly well so far.
"Liverpool have two games to play then we see the gap. There are 14 games to play, many points to play for and more tough games like today."
Christian Eriksen was not among the Brentford squad as he edges slowly towards a return to football after suffering a cardiac arrest just eight months ago at Euro 2020.
But they may need some inspiration from the Dane to survive their first season in the English top flight for 74 years.
A bright start means Thomas Frank's men still have a six-point cushion over the bottom three, but they are the fading force and all the sides below them in the table have games in hand.
"It's very important to look at the performance and our work ethic and attitude," said Frank. "I would say our last four performances have been good, so if we keep the mentality high and stay positive then we will be fine."