Atletico's win moved them to within six points of leaders Barcelona, who host Levante on Sunday, and kept them two points clear of third-placed Valencia, who are on 37 points after coming back from an early deficit to beat Girona 2-1 thanks to a first-half Janos Ramalho own goal and Daniel Parejo's penalty three minutes after the break.
Costa, playing his first La Liga game since rejoining Atletico from Chelsea following the end last week of the Spanish club's transfer ban, had already been booked for a foul in the 62nd minute with the hosts 1-0 up through Angel Correa when six minutes later he met a low cross to double his side's lead and spark wild celebrations.
The brooding striker looked totally perplexed by the decision but his coach Diego Simeone said he deserved to be sent off.
"The referee was unable to consider the emotional aspect (of Costa's behaviour), the rules are the rules," Simeone said after the game.
More From This Section
"If you go and celebrate with the fans, the yellow is deserved. We must accept that."
Simeone's side looked as hard to beat as ever -- with just eight goals conceded and one defeat in 18 league games -- but they have scored only 27 with Antoine Griezmann struggling to find the net, hitting just five league goals so far.
Sevilla stay fifth on 30 points after the defeat in a fiery derby clash that saw nine yellow cards dished out and both sides hit the woodwork, one point behind Real, who travel to Celta Vigo on Sunday.
Betis jump six places up to eighth on 27 points after just their second win since October, which came thanks to goals from Fabian, Zuohair Feddal, Riza Durmisi, Sergio Leon and Cristian Tello.
Quique Setien's side won the derby in two second half minutes, when Durmisi and Leon struck to make what had been a tight derby 4-2 to Betis.