Brais Mendez had given the home team the lead early on but they failed to take their chances to put the game to bed and Martinez pounced late on to punish them.
City were racking up the chances too, but seemed unable to take any of them, or even seriously test Chelsea goalkeeper Dorde Petrovic despite piling on the pressure in the second half.
Much of the pre-match talk from the Manchester City camp revolved around the desire to give Pellegrini a glorious send-off following confirmation that Bayern Munich coach Pep Guardiola will take his job from next season.
It had taken Sevilla just five minutes to take the lead as Wissam Ben Yedder tapped in from close range after home defender Dejan Lovren fell over while trying to clear the ball.
The win leaves City level on points with Liverpool, who play Sheffield United at Anfield on Thursday night, and a point behind Arsenal, who top the table after beating Luton Town.