Aguero converted from close range after Pablo Zabaleta's cross had been helped on by David Silva with only seconds remaining of the three minutes of added time in a memorable finish at Eastlands.
The result will come as welcome relief to manager Roberto Mancini who had set his side a target of ten points to reach the next phase, a mark now within their grasp with three games remaining.
But Villarreal were incensed at the winning goal, presumably claiming for an offside, and their players surrounded the officials on the final whistle.
The pre-match build-up had emphasised the importance of City recording their first ever Champions League victory against the Spanish visitors, which made the opening four minutes all the more potentially damaging for the world's self-styled wealthiest club.
City were still trying to settle into a rhythm when Silva's sloppy play outside his area placed Nigel de Jong in trouble as he lost the ball to Jonathan De Guzman.
The Villarreal playmaker found former United youngster Giuseppe Rossi whose shot from the edge of the box was fumbled by Joe Hart and Cani reacted first to guide the rebound into the City goal.
To their credit, City responded well, while always looking susceptible to the counter-attack, although it took them until the 42nd minute to convert chances into the equalising goal.
It came from the impressive City left-back Aleksandar Kolarov whose low cross was destined for Edin Dzeko inside the Villarreal six-yard area until defender Carlos Marchena slid in and guided the ball into his own goal.
The restart found Giuseppe Rossi continuing to be a thorn in City's side with a number of sights of goal, one of which forced Hart into a full-length diving save after 47 minutes.
But the best opening of the early exchanges fell to City, with Zabaleta picking out Dzeko close to goal and the forward forcing Lopez into another impressive block.
Cristian Zapata's rampaging run ended with Hart once more required to show good handling skills in the soaking conditions and Mancini, realising the seriousness of the situation, threw on Aguero, judged fit but not fit enough to start the game, after just over an hour.
There was no instant improvement, the best City could muster over the next quarter-hour coming, yet again, from Kolarov whose brilliantly-hit free-kick landed in the Villarreal side netting.
To add to the mounting frustration, Dzeko found himself clean through after 77 minutes from an Aguero pass but failed to even test Lopez, his effort flying well off target.
Another poor miss from Dzeko and a Zabaleta shot, which was placed too close to the goalkeeper, followed although the late winner eased those City frustrations considerably.
Source: AFP
Source: AFP