Cristiano Ronaldo converted a stoppage-time penalty won by Gareth Bale to seal a 2-0 victory for Real Madrid against Malaga on Saturday, allowing Carlo Ancelotti's side to maintain the pressure on Primera Division leaders Barcelona and Atletico Madrid.
Los Blancos led 1-0 thanks to a fortuitous goal from Angel Di Maria just after half-time, but then spent bulk of the second period being frustrated by some outstanding saves from Malaga goalkeeper Willy Caballero as they sought a second goal.
However, the clincher duly arrived in added time. Ronaldo, who had had a frustrating afternoon, crashed a spot-kick into the bottom corner after 76th-minute substitute Bale had chased a long ball before going to ground under a challenge from Weligton.
The visitors barely troubled Madrid going forward but were able to keep the hosts at bay for most of the game - something that will worry Ancelotti ahead of a crucial seven days in which his side host Juventus in the Champions League and then travel to Barcelona for the first Clasico of the season.
Alvaro Morata was handed his first Real start of the campaign after Karim Benzema failed to recover from a knock he picked up during the week.
The 20-year-old academy graduate impressed the home supporters with his energetic performance, and was unlucky not to get on the scoresheet. He received a standing ovation when he made way for Bale on 74 minutes.
The first attempt of the game fell to the visitors, but Diego Lopez comfortably gathered Samuel's soft shot from outside the area.
Sergio Ramos had Madrid's first effort, heading wide a Di Maria free-kick.
Ronaldo came closer a few minutes later, turning inside the box and directing a shot towards the far corner, but it bounced off the post and out.
Di Maria later had a free-kick tipped wide by Caballero, then shot wildly over the bar from distance.
Then came Madrid's best chance of the first half. Asier Illarramendi broke up a Malaga attack and Madrid launched a lightning quick counter-attack. Di Maria found Ronaldo on the left wing and the Portugal forward ran towards goal before beating Caballero only to send his shot inches beyond the far post.
Morata then nearly turned in a cross from Di Maria, but Caballero caught it.
A few minutes later, the 20-year-old did have the ball in the net, but he was caught offside.
Ronaldo was then denied by the hand of Caballero, while Eliseu failed to hit the target in a rare attack from the visitors.
Madrid went ahead a minute into the second half. Di Maria tried to pick out Ronaldo in the box with a cross from the right, and, even though the former Manchester United man was unable to get on the end of it, the ball sailed into the bottom corner beyond Caballero.
Di Maria then gave Isco the perfect opportunity to score against his old club, but this time Caballero was equal to the shot and pushed it away.
The goalkeeper was easily Malaga's best player, helping keep the scoreline respectable, and he denied Ronaldo again with 17 minutes remaining, fisting away a free-kick which had looked destined for the top corner.
Malaga substitute Bobley Anderson gave the home crowd a scare when he was allowed to shoot on goal with 12 minutes left, but his attempt flew just wide, although Lopez had it covered.
Substitute Jese Rodriguez then presented Ronaldo with a golden chance to grab the second, but the forward - five yards from goal - took an extra touch and did not get enough accuracy on his shot, allowing Caballero to stick out a leg and save it.
The Argentinian goalkeeper was called into action again towards the end of the game, making a stunning save from Jese, and was at it again later to keep out a near-post thunderbolt from Ronaldo.
However, he was beaten for a second time in stoppage time. Bale pursued what appeared to be a lost cause, showing incredible guile and strength to get past defender Weligton before hitting the turf. The referee signalled a penalty and Ronaldo was finally able to get his name on the scoresheet.