Atleti looked destined to hold on for at most a draw after Mario Hermoso was shown a straight red card for a foul on Loren Moron, but substitute Costa steered home Yannick Carrasco's free-kick in the 74th minute to secure a top-four finish for Diego Simeone's men.
After seeing goals for Angel Correa and Alvaro Morata overturned by VAR, there were concerns Costa's header would be ruled out during a lengthy check for handball.
However, the goal was allowed to stand, ensuring Atleti will return to European football's top table in 2020-21.
