Sterling has often been criticised for his finishing in the past but is averaging a goal every 89 minutes this season following his victor in Tuesday's 1-0 victory over Feyenoord in the Champions League.
Manchester City have defeated Huddersfield 2-1 in the last hour in an English Premier League match.
Their lead was erased within two minutes of the restart when Sergio Aguero calmly converted a penalty after Sterling was brought down by Scott Malone.
City were made to work hard for all three points after they went in at the break 1-0 down when Argentina worldwide Nicolas Otamendi deflected a corner into the back of his own net.
His goal at Huddersfield was his 12th in 18 appearances in all competitions this season.
Raheem Sterling proved the difference maker as it was the England worldwide who won the penalty which Aguero duly put past Lossl in the Huddersfield goal.More news: Uber recognises need for consumer trust after breach cover up
Guardiola, whose side have dropped points in just one of their 13 Premier League games this season, said: "We said that we needed this situation to happen - you have to live it, to be in trouble".
There was some fortune attached to the winning goal.
"I have said many times it is impossible that we will finish unbeaten because you play a lot of games every three days".
"But if you fight to avoid that mentally and in the way we want to play, that's fantastic". "The guys competed amazingly, which is why we won".
Guardiola says they must match Huddersfield's desire and knows how unsafe they can be after drawing 0-0 there last season in the FA Cup.