A calamitous miskick by Villa goalkeeper Brad Guzan allowed Sergio Aguero to put City ahead in the third minute and Aleksandar Kolarov extended the hosts' lead with a 66th-minute free-kick.
Tom Cleverley and Carlos Sanchez hit back for Villa, punishing errors by City goalkeeper Joe Hart in the 68th and 85th minutes, only for Fernandinho to claim victory with a back-post finish from Kolarov's left-wing corner.
“Today we didn't play well, but we had the spirit and fight to win in the last five minutes despite their late equaliser,” said City manager Manuel Pellegrini.
“I was not satisfied with the way we played today, but sometimes you need different things to win games.”
The win left the defending champions nine points below leaders Chelsea, having played two games more, and took them above Arsenal and Manchester United.
Arsenal, a point back with two games in hand, visit Chelsea on Sunday, while fourth-place United travel to Everton.
It was a cruel outcome for Tim Sherwood's Villa, victorious against Liverpool in last weekend's FA Cup semi-final, and left them two points above the relegation zone, having played a game more than the three teams directly below them.
Sherwood felt that Villa had been denied a “blatant” penalty moments before Fernandinho's goal when Christian Benteke was adjudged to have been marginally offside when he went down under a challenge from Hart.
“I could see from where I was that Christian Benteke was onside and I think it was a penalty and a red card for Joe Hart,” he told the BBC.
Elsewhere, Liverpool failed to make ground on the Champions League places after drawing 0-0 at West Bromwich Albion in captain Steven Gerrard's 500th league game.
Brendan Rodgers's team are seven points below the top four in fifth place, but they remain in pole position in the Europa League qualifying race after Tottenham Hotspur drew 2-2 at Southampton.
Graziano Pelle twice put Southampton in front at St Mary's, but Spurs responded on both occasions, first through Erik Lamela, who appeared to score with his arm, and then via Nacer Chadli.
“I was focused on my job, but it was a very tough and emotional game for me,” said Spurs head coach Mauricio Pochettino, who left Southampton last year.
“It was difficult because I still love Southampton and I have very good memories here.”
Tottenham, sixth, trail Liverpool on goal difference and remain a point above Southampton.
The teams finishing fifth and sixth will qualify for the Europa League, while victory for Arsenal over Villa in the FA Cup final would also send the team finishing seventh into Europe's second-tier competition.
At the other end of the table, Burnley, Queens Park Rangers and Sunderland slipped closer to the relegation trapdoor as Leicester City and Hull City recorded timely victories.
Bottom club Burnley lost 1-0 at home to Leicester in agonising circumstances, with Jamie Vardy notching a 60th-minute winner for the visitors just seconds after Burnley's Matt Taylor had hit the post with a penalty.
“The players have deserved the breaks they've got, through a lot of honesty, hard work and ability,” said Leicester manager Nigel Pearson, whose side climbed out of the bottom three after a fourth successive win.
“But if people think the hard work's done, they're in for a shock.”
Burnley are now five points adrift of safety and QPR are just a point better off following a 0-0 draw at home to West Ham United in which Charlie Austin had a penalty saved by Adrian.
Sunderland sank into the relegation places after a 1-1 draw at Stoke City, who equalised through a powerful Charlie Adam strike after Connor Wickham had given the visitors a first-minute lead.
Hull capitalised on their rivals' slip-ups by ending a six-game winless run with a 2-0 victory at Crystal Palace, courtesy of a second-half brace from Dame N'Doye.
Newcastle United are also in danger of being sucked into the relegation scrap after a 3-2 loss at home to Swansea City that left them five points above Sunderland.
Ayoze Perez gave John Carver's side a 20th-minute lead, but Swansea hit back through Nelson Oliveira, Gylfi Sigurdsson and Jack Cork before Siem de Jong claimed a late consolation for the hosts.
Newcastle have now lost seven consecutive league games for the first time since 1977. – AFP
Original source: Late City goal sinks Villa