Atletico fell behind in the first minute, when sloppy defending allowed Andreas Ivanschitz to score.
It took the home side time to settle, but when they did Diego Godin headed them level in the 30th minute and Costa volleyed home two minutes after the break.
Pedro Rios scored on the counterattack to make it 2-2, but Atletico got their winner when Juanfran Torres was fouled in the box by Ruben Garcia and Costa converted the penalty for his 19th goal of the season.
He leads the scoring charts in La Liga with two more than Cristiano Ronaldo.
Levante's Juanfran Garcia was sent off in the dying moments for a clash with Felipe Luis.
Atletico go into the winter break with 46 points and a 100 per cent home record. Barcelona, second with 43 points, can draw level with a win at Getafe on Sunday.
Real Madrid, eight points adrift of Atletico, face Valencia on Sunday.