Atletico Madrid had substitute Vitolo to thank as they boosted their prospects of Champions League football next season with a 1-0 win over Real Valladolid at the Wanda Metropolitano.
A clutch of chances had been spurned by the time Vitolo came off the bench to replace Marcos Llorente with 17 minutes remaining, with Joao Felix and Alvaro Morata going close.
When the breakthrough came in the 81st minute it was dramatic, Vitolo heading at goal after a corner from the left reached him at the far post.
Valladolid defender Kiko Olivas felt he had nodded it off the line after diving spectacularly to reach the ball, but replays showed it was six inches over and Atletico moved back up to third.
Waldo Rubio almost gave Valladolid a phenomenal start, driving into space and lashing a 25-yard strike that Jan Oblak had to throw himself to his right to palm over the crossbar.
At the other end, Morata headed wastefully off target from Hector Herrera's excellent cross before an off-balance Joao Felix sliced high and wide.
Joao Felix went close again, this time with the ball fully under his control, as he darted forwards and sent a shot just wide of the left post.
Valladolid's Matheus Fernandes went similarly close on the half-hour mark, as Atletico's threat briefly flatlined.
Morata made way for Diego Costa in the 64th minute and the new arrival quickly had the ball in the net, but he had strayed offside.
Thomas Partey almost broke the deadlock with a 35-yard howitzer that Jose Antonio Caro did well to turn away for a corner in the 80th minute.
From that set-piece Atletico had their moment through Vitolo. Olivas was confident he had reached the ball in time, but a VAR check told a different story.
What does it mean? Simeone's side scrape through
This was by no means a classic Atletico performance, but they never gave up the pursuit of a winning goal. Thomas' thumping shot almost provided a match-winner to cherish, but it helped to bring about the outcome Diego Simeone's men were seeking. Valladolid, in lower mid-table but surely just about safe, gave a decent account of themselves.
Vitolo makes his mark
Vitolo was in the right place at the right time, keeping his composure as the ball came through a thicket of players. With Caro stranded, it seemed he just had to hit the target, but his heart would have been in his mouth as Olivas spotted the danger and almost pulled off the spectacular.
Caro was barely clinging on
The longer this match went on, the more likely it seemed that Caro's good fortune would run out. He was left embarrassed by the goal, coming off his line and failing to punch away the corner from which the winner arrived.
Atletico go to Levante on Tuesday, when Valladolid have home advantage against high-flying Getafe.