Yaya Toure struck twice as he went past 50 goals in the Premier League and James Milner was also on target before Wilfried Bony, on as a late substitute, scored against the club he left in January.
Swansea’s defeat means their hopes of Europa League qualification are definitely over as Garry Monk’s men will finish eighth.
But they gave City an almighty scare after falling 2-0 behind inside 36 minutes, levelling through Gylfi Sigurdsson and Bafetimbi Gomis, before the deposed Premier League champions had their England goalkeeper Joe Hart to thank for some outstanding saves.
Hart produced possibly the save of the season when his his flying one-handed stop prevented Federico Fernandez’s 82nd-minute header from making it 3-3.
The England goalkeeper made another point-blank save from Bafetimbi Gomis two minutes later before Bony, on as a late substitute, settled matters in injury time with only his second City goal.
“It was a beautiful save in a very important moment,” Pellegrini said after his side had tightened their grip on second spot with a fifth consecutive league victory.
“Joe is the number one goalkeeper in England and I think he has improved a lot this season.
“Bringing Willy Caballero was good for him, giving him good competition and also working with the goalkeeping coach Xabier Mancisidor.
“It’s important for him but he most important thing is he has an open mind. He is only 28 years old and he must improve in a lot of things, but he is working hard to do it.
“There are three or four good goalkeepers in this league, but Joe must improve and not think he knows every thing at this moment. Every day he works hard.”
James Milner scored City’s second goal and gave another performance full of endeavour and commitment, even though he is out of contract at the end of the season and he may move on this summer.
Pellegrini stressed he wants Milner to stay admitted the final decision rests with the player himself.
“It’s a decision James must take at the end of season, what is better for his future,” Pellegrini said.
“I always talk that he is an important player for our team, he can play in different positions because he is an intelligent player.
“He always gives 100 per cent but it will be sorted at the end of the season.
“I can think (staying at Manchester City) is best him for hims.”
Swansea manager Gary Monk said missing out on Europe should take nothing away from a campaign which has seen Swansea record their highest-ever Premier League finish and their greatest points tally.
“I think we’ve shown quite clearly with the run of form we’ve been on that we wanted to get into Europe,” Monk said.
“We pushed all the way to try to get there and it would have been a great reward for the season we’ve had.
“But hopefully now we have a chance to recruit properly and try to surpass what we have done this year in the Premier League, although we know it will be tough.”
Swansea were criticised by Arsene Wenger for what the Arsenal manager perceived as negative tactics in the Welsh club’s 1-0 smash-and-grab victory at the Emirates Stadium.
But Monk said this performance showed that Swansea could take on the best in an attacking contest.
“We got criticised last Monday for apparently not playing football, and I wanted the players to show we can go toe-to-toe with one of the top sides when we choose to,” Monk said.
“I think we proved we can do that. Yes we lost the game, but if we had taken one or two chances, or Joe Hart had not made some incredible saves, we could have got something from the game.
“We didn’t quite get a result, but I think we have shown what a strong group we’ve got and hopefully next season we can be even better.”
Fabianski, Richards, Fernandez, Williams, Taylor, Cork, Shelvey (Britton 78), Dyer (Barrow 73), Sigurdsson (Emnes 83), Montero, Gomis
Hart, Zabaleta, Demichelis, Mangala, Kolarov, Y Touré (Bony 85), Fernandinho (Kompany 80), Milner, Lampard (Jesús Navas 59), Silva, Agüero