Miranda produced a towering header to break the deadlock before Costa netted a penalty.
Brazilian defender Miranda grabbed his second goal of the season in the Spanish top flight 18 minutes from time, after David Villa had failed to convert a second-half penalty.
Costa, who missed a penalty at Getafe last weekend, then secured the points from the spot with his 35th goal of the season, after Cristian Sapunaru had brought him down — and received a second yellow card — in added time.
Diego Simeone's side had been frustrated by relegation-threatened Elche at a packed Vicente Calderon before Miranda and Costa secured an eighth consecutive La Liga victory.
With Barcelona not playing until Sunday and Real Madrid out of action this weekend, Atleti now has an ominous advantage at the summit with four games remaining as it attempts to win its first La Liga title since 1996.
It can head into Tuesday's Champions League semifinal first leg against Chelsea knowing it has a great chance of securing a famous double. Defeat for Elche, on the other hand, keeps it only four points above the relegation zone.
Costa suffered a leg wound in a collision with a post in the victory at Getafe last weekend, but the striker was deemed fit to start. And the Spain international was soon in the thick of the action when he fired into the side netting after Adrian Lopez laid the ball off to him five minutes in.
Elche was not content to just make up the numbers, though, and Thibaut Courtois produced a fine save to keep out a left-footed strike from Javi Marquez before then having to be alert to thwart Damian Suarez when the defender was allowed a free header from the resulting corner.
Filipe Luis fluffed his lines at the other end when the ball fell kindly for him in the penalty area before the home side was given another scare just before the half-hour mark, as Carles Gil fired over the crossbar from inside the area.
Atleti was not at its best in the first half, but ought to have been in front four minutes before the break when Costa flicked on Juanfran's cross and David Villa prodded wide with the goal gaping. Villa had appeared to be in an offside position, but the flag failed to go up.
Simeone replaced Adrian with Raul Garcia at the break and the substitute took only four minutes to make an impact, as Sapunaru was ruled to have bundled him over in the area and Carlos Clos Gomez pointed to the spot.
Villa stepped up to take the resulting penalty after Costa's miss against Getafe, but the former Barcelona man also failed from the spot as Manu Herrera kept out a tame effort diving to his left.
There was more frustration for Villa when he had a goal ruled out for offside and was then substituted to ensure Elche remains the only current top-flight team he has failed to score against.
Costa was booked following his reaction to two strong challenges, which sparked a melee that also saw Alberto Rivera go into the book.
An animated Simeone orchestrated the Atleti faithful and the opening goal they craved eventually arrived when Miranda rose highest to head home Jose Sosa's corner in emphatic fashion.
Costa then raced clear and was denied by Herrera, but made no mistake when he sent the keeper the wrong way from the spot after Sapunaru had upended him in the 90th minute. The defender was shown a second yellow card to compound his misery.