Sergio Aguero's winner in the dying seconds rescued Manchester City as they came from behind to claim their first Champions League win.
Roberto Mancini's side looked set for more frustration after Villarreal belied their poor La Liga form to leave City on the brink of a third game without victory in the group stage.
Cani had set the tone for an uncomfortable evening when he gave Villarreal the lead after only four minutes and City's only response was an own goal from Carlos Marchena just before the interval.
But deep into stoppage time, and with what turned out to be almost the final kick of the game, substitute Aguero arrived at the far post to turn Pablo Zabaleta's cross past Diego Lopez to revive City's hopes of reaching the knockout phase.
CITY'S REMAINING GAMES
- 2 Nov - Villarreal (a)
- 22 Nov - Napoli (a)
- 7 Dec - Bayern Munich (h)
A draw would not have been fatal for City, but it would have left them with a tough task after drawing with Napoli at the Etihad and losing to Bayern Munich in Germany.
And it was left to Argentine Aguero, on as a second-half substitute, to come to City's rescue with a poacher's finish that left Villarreal devastated that such a fine performance had left them empty-handed.
It also came as sweet relief to Mancini after City's off-colour display saw him replace Adam Johnson with Gareth Barry after only 39 minutes, much to the player's obvious displeasure.
Mancini had to deal with Edin Dzeko's unhappiness at being substituted and the Carlos Tevez affair in Munich - but this just appeared a case of genuine disappointment from Johnson.
All this was forgotten as City's players celebrated at the final whistle in the hope that this dramatic finale will see their Champions League campaign now gather momentum.
Mancini made it clear before kick-off that victory was the only priority - no matter how it was achieved after picking up only one point from their opening two games.
City made the worst possible start, however, as they fell behind in the fourth minute. The normally impeccable David Silva conceded cheap possession and when keeper Joe Hart could only push out former Manchester United striker Giuseppe Rossi's shot Cani was able to turn in the rebound.
The goal was greeter in virtual silence, a mixture of stunned City fans and the fact that Villarreal had only brought a tiny band of travelling fans to Manchester.
City attempted to build momentum with Aleksandar Kolarov prominent, forcing Lopez into a smart save from an angled free-kick and sending another long-range effort flashing across the face of goal.
As the home fans grew more impatient, Mancini illustrated the scale of his concern by making the tactical substitution six minutes before the interval - a decision that saw the England winger depart shaking his head.
The mood of discontent was swiftly replaced by delight as City drew level after 43 minutes. Kolarov was again involved with a cross that was destined for Dzeko, only for Marchena to get their first and turn the ball into his own net.
Dzeko's performance had left much to be desired, but he could have made amends two minutes after the restart when Zabaleta found him unmarked in the area. He found the target but Lopez made a fine diving save.
DID YOU KNOW?
- Sergio Aguero scored five goals in only eight appearances versus Villarreal for Atletico Madrid in La Liga
Rossi had looked a class act throughout and he gave Hart another moment of anxiety after 51 minutes when he could only push his shot away and fortunately for City there was no-one from Villarreal on hand to take advantage.
Mancini made another change after 62 minutes when Aguero, now recovered from a groin injury, came on for Nigel de Jong.
Villarreal were keeping City at arm's length with very few alarms, comfortable in possession and with a simple approach that was serving them well.
City were unable to build up any pressure, although they did carve out a clear chance with four minutes left, only for Dzeko to direct Kolarov's inviting cross tamely wide.
Zabaleta also wasted a headed chance but then played a crucial part in that dramatic climax. His cross was touched on by Silva and Aguero arrived to score.
There was barely time to kick-off and a scene of total frustration had been instantly transformed into one of celebration.
Live Text Commentary
Full Time The game is over, as the referee blows his whistle.90:00 +3:02
Assist by Pablo Zabaleta.90:00 +3:02 Goal scored
Goal! - Sergio Aguero - Man City 2 - 1 Villarreal Sergio Aguero finds the net with a goal from close range to the bottom left corner of the goal. Man City 2-1 Villarreal.90:00 +1:53 Booking
Booking Perez Martinez Mario is shown a yellow card for unsporting behaviour.90:00 +0:53
Pablo Zabaleta takes a shot. Save by Rodriguez Diego Lopez.88:38
Free kick awarded for an unfair challenge on Marcos Gullon by Edin Dzeko. Direct free kick taken by Gonzalo Rodriguez.87:47
Outswinging corner taken left-footed by Aleksandar Kolarov, Gonzalo Rodriguez makes a clearance.87:28 Substitution
Substitution Marcos Gullon comes on in place of Jonathan De Guzman.85:53
Headed effort on goal by Edin Dzeko from inside the penalty box misses to the right of the target.83:10
Shot by Mubarak Wakaso. Blocked by Gareth Barry.82:08
Borja Valero takes the inswinging corner, clearance by Gnegneri Toure Yaya.81:42 Substitution
Substitution Perez Martinez Mario comes on in place of Ruben Cani.80:44
The referee blows for offside. Free kick taken by Rodriguez Diego Lopez.80:02 Substitution
Substitution James Milner joins the action as a substitute, replacing Samir Nasri.79:52 Substitution
Substitution Mubarak Wakaso comes on in place of Hernan Perez.78:43
Edin Dzeko fouled by Carlos Marchena, the ref awards a free kick. Gnegneri Toure Yaya takes the direct free kick.77:08
Free kick awarded for an unfair challenge on Gareth Barry by Borja Valero. Direct free kick taken by Gareth Barry.76:32
Edin Dzeko produces a right-footed shot from inside the area that clears the crossbar.75:17
Jonathan De Guzman has an effort at goal from outside the box which goes wide left of the target.74:42
Jose Manuel Catala fouled by David Silva, the ref awards a free kick. Direct free kick taken by Borja Valero.
Handball by Edin Dzeko. Soriano Bruno takes the direct free kick.72:55
Free kick awarded for an unfair challenge on David Silva by Borja Valero. Strike comes in from Aleksandar Kolarov from the free kick.69:59
Foul by Borja Valero on Gnegneri Toure Yaya, free kick awarded. Free kick taken by Gareth Barry.69:42
Hernan Perez crosses the ball.66:57 Booking
Booking The referee shows Giuseppe Rossi a yellow card.66:39
The assistant referee signals for offside against Edin Dzeko. Jose Manuel Catala takes the indirect free kick.65:41
The offside flag is raised against Jonathan De Guzman. Indirect free kick taken by Joe Hart.64:20
Free kick awarded for a foul by Gnegneri Toure Yaya on Jonathan De Guzman. Jose Manuel Catala restarts play with the free kick.64:05
The ball is crossed by Aleksandar Kolarov.61:20
Vincent Kompany takes the direct free kick.61:20 Substitution
Substitution Nigel De Jong leaves the field to be replaced by Sergio Aguero.61:20
Jonathan De Guzman concedes a free kick for a foul on Nigel De Jong.60:19
Cristian Zapata takes a shot. Joe Hart makes a save.57:53
Borja Valero has an effort at goal from outside the penalty box missing to the wide right of the goal.57:07
Corner from right by-line taken by Borja Valero.56:09
Aleksandar Kolarov is ruled offside. Free kick taken by Rodriguez Diego Lopez.55:23
Borja Valero produces a right-footed effort from long distance that goes harmlessly over the bar.54:37
The referee blows for offside against Aleksandar Kolarov. Indirect free kick taken by Rodriguez Diego Lopez.53:06
Effort on goal by Ruben Cani from long distance goes over the crossbar.52:25
Jonathan De Guzman takes the outswinging corner, clearance by Edin Dzeko.51:11
Giuseppe Rossi takes a shot. Save by Joe Hart.49:44
Giuseppe Rossi produces a drilled left-footed shot from deep inside the penalty area which goes wide of the left-hand post.47:15
Outswinging corner taken from the left by-line by Aleksandar Kolarov, clearance by Soriano Bruno.46:53
Edin Dzeko takes a shot. Rodriguez Diego Lopez makes a save.45:16
Giuseppe Rossi has an effort at goal from just outside the box which goes wide of the left-hand post.45:01
The match restarts for the second half.45:00 +1:05 Half time
Half Time The whistle is blown to end the first half.44:58
Samir Nasri takes a shot. Rodriguez Diego Lopez makes a save.44:17
The assistant referee flags for offside against Gnegneri Toure Yaya. Free kick taken by Rodriguez Diego Lopez.44:03
Edin Dzeko takes a shot. Save made by Rodriguez Diego Lopez.43:36
Shot from just outside the area by Jonathan De Guzman goes over the bar.42:40
The ball is sent over by Aleksandar Kolarov, blocked by Carlos Marchena.42:40 Goal scored
Goal! - Carlos Marchena - Man City 1 - 1 Villarreal Carlos Marchena scores an own goal. Man City 1-1 Villarreal.39:31
Inswinging corner taken by Aleksandar Kolarov from the right by-line.39:31 Substitution
Substitution Adam Johnson leaves the field to be replaced by Gareth Barry.38:16
Aleksandar Kolarov produces a cross.37:18
Gnegneri Toure Yaya has an effort at goal from just inside the box that misses to the right of the target.35:42
Samir Nasri sends in a cross.35:00
Shot by Gnegneri Toure Yaya. Soriano Bruno gets a block in.34:38
Foul by Ruben Cani on Samir Nasri, free kick awarded. Samir Nasri restarts play with the free kick.34:09
Unfair challenge on Gonzalo Rodriguez by Edin Dzeko results in a free kick. Soriano Bruno takes the direct free kick.32:04 Booking
Booking Jose Manuel Catala is cautioned.31:01
Free kick awarded for an unfair challenge on Nigel De Jong by Borja Valero. Free kick taken by Nigel De Jong.23:35
The offside flag is raised against Samir Nasri. Free kick taken by Carlos Marchena.22:36
David Silva takes a shot. Save by Rodriguez Diego Lopez.20:31
Nigel De Jong produces a right-footed shot from just outside the area that goes harmlessly over the bar.20:13
Inswinging corner taken from the right by-line by Adam Johnson.19:12
Free kick awarded for an unfair challenge on Adam Johnson by Soriano Bruno. Aleksandar Kolarov has a direct shot on goal from the free kick, save by Rodriguez Diego Lopez.17:27
Corner taken by Aleksandar Kolarov played to the near post, Jose Manuel Catala makes a clearance.15:24
Jose Manuel Catala concedes a free kick for a foul on Adam Johnson. David Silva restarts play with the free kick.14:38
Edin Dzeko delivers the ball.13:55
Cristian Zapata concedes a free kick for a foul on David Silva. Direct free kick taken by David Silva.13:17
Edin Dzeko is flagged offside by the assistant referee. Rodriguez Diego Lopez takes the free kick.12:40
Effort on goal by Samir Nasri from just inside the penalty area goes harmlessly over the target.11:20
Aleksandar Kolarov has an effort at goal from a long way out that goes wide of the right-hand post.9:50
Hernan Perez crosses the ball, Joleon Lescott makes a clearance.9:13
The ball is swung over by Aleksandar Kolarov, clearance by Carlos Marchena.8:19
Pablo Zabaleta concedes a free kick for a foul on Ruben Cani. Direct free kick taken by Borja Valero.6:22
The official flags Edin Dzeko offside. Indirect free kick taken by Carlos Marchena.4:55
Aleksandar Kolarov concedes a free kick for a foul on Borja Valero. Jonathan De Guzman takes the direct free kick.3:09
Giuseppe Rossi has a drilled shot. Save made by Joe Hart.3:12 Goal scored
Goal! - Ruben Cani - Man City 0 - 1 Villarreal A goal is scored by Ruben Cani from close in low into the middle of the goal. Man City 0-1 Villarreal.0:50
The official flags Aleksandar Kolarov offside. Rodriguez Diego Lopez takes the indirect free kick.0:31
Foul by Hernan Perez on Aleksandar Kolarov, free kick awarded. Direct free kick taken by David Silva.0:00
The ref blows the whistle to start the match.
Live data and text provided by our data suppliers