An own goal from Gary Cahill in the closing stages of the first half saw City break the deadlock, and they spurned a number of gilt-edged opportunities to extend their lead after the break.
Most notable was a shocking miss from Kevin De Bruyne, who smashed a close-range shot against the crossbar with the goal gaping, when it had seemed easier to score.
Costa then equalised on the hour mark, before turning provider for Willian to hand Chelsea the lead.
Eden Hazard put the result beyond doubt to make it 3-1 and City finished with nine men when Fernandinho and Sergio Aguero were sent off in a tempestuous finale.
"We are working very well tactically, everyone knows what we have got to do," Diego Costa told Sky Sports afterwards. "Manchester City had opportunities to score a second goal, but they missed.
"We got more confidence when we levelled the scoring, then got another opportunity to score and we took it.
"It was a great game."
Cahill, meanwhile, enthused about Chelsea's overall performance and believes they showed the requisite character to further extend their unbeaten run.
"We gave everything on the pitch," the defender added. "It was a test for us. It shows another side to our football.
"That is eight wins now, which we can build on."