The French side wasted several clear-cut chances before Maxwel Cornet rifled in an angled drive to give them an early second-half lead.
City defender Aymeric Laporte quickly levelled with a header but Cornet fired in again to put Lyon on top of Group F.
However, Sergio Aguero reacted quickest to flick in a header two minutes later to ensure City remain in pole position to top the group.
“We are so delighted and so happy,” Guardiola said. “It is a big compliment for the team.
“We played one of toughest teams we’ve ever faced. They are physical, strong, they counter-attack incredible.
“We reacted after 1-0 and 2-1 and we are in the final stages. This was our target.
“Now we must try to get a point to finish first in the group stage, but it is so important to go through.”
Even without the point, Guardiola’s side would still have clinched their place in the knockout stage for the sixth successive season after Shakhtar Donetsk snatched a late 3-2 victory at Hoffenheim.
But it meant City know a draw in their final game against the already-eliminated German side will be enough to progress as group winners.
Finishing top would ensure City will not be drawn against another group winner – with the likes of Real Madrid, Bayern Munich and Juventus currently topping their groups – in the last 16.
Lyon looked set to join City in qualifying for the knockout stage with the draw, until Shakhtar’s late winner in another breathless finish.
The French side still need a point in their final game against Shakhtar in Ukraine to progress.