With two games left, Madrid will be crowned champions if they beat Villarreal at home on Thursday regardless of how Barca fare at the Camp Nou against Osasuna.
But they were made to sweat by a Granada team that are gunning for Europe and have been arguably the division’s surprise of the season after being promoted from second tier only last year.
Ferland Mendy and Karim Benzema looked to have set Madrid on course for a comfortable win at Los Carmenes but Granada were transformed after the break and Darwin Machis’ 50th-minute strike gave them hope.
An increasingly nervy Madrid were clinging on by the end and needed Sergio Ramos to clear one shot off the line as Zinedine Zidane’s side dug in for a ninth consecutive victory.
When the final whistle blew, Zidane roared with relief and Ramos clenched his fists after coming through their toughest test since the restart.
“We can’t relax, we’re a bit closer but we have to carry on,” said Ramos afterwards.
“We let our guard down here a bit on the second half. We won the first half and lost the second and maybe that’s a warning for us. We have to make sure we don’t repeat that mistake.”
Madrid could win a third La Liga title in eight years at the Alfredo di Stefano Stadium on Thursday night. “It would mean a lot,” said Ramos.
“It’s the prize for consistency over the whole year. Maybe we had a period of reflection during the suspension and we came back and reacted. We’re in the race and hopefully on Thursday we can celebrate.”
If Madrid slip up against Villarreal, they will still have a second chance on Sunday when they finish away at Leganes while Barcelona visit Alaves.
Machis’ goal was the first Madrid have conceded in six matches but few would have seen it coming after the first half.
Madrid scored twice in six minutes, with both goals coming from breaks down their left. Mendy had space in front of him and kept going, accelerating between Victor Diaz and Dimitri Foulquier before firing high and into the roof of the net from an acute angle.
The second goal came down the same side, Isco’s backheel allowing Luka Modric to switch left to Benzema, who this time cut inside Diaz and shot into the far corner.
Madrid cruised through the rest of the half, pushing the ball around at will, but comfort perhaps created complacency and Granada improved after the break.
Machis pulled a goal back, striking through the legs of Courtois after Casemiro was robbed in midfield and Madrid were rattled as Granada dictated more and more of the ball.
A scramble in Madrid’s six-yard box saw several players hacking at the ball in panic and Courtois was twice required to make smart saves late on.
The closest Granada came was when the ball fell to Ramon Azeez at the back post and he fired towards the near post with Courtois stranded. Ramos was there on the line.
Download our app and read this and other great stories on the move. Available for Android and iOS.