Ronaldo's wayward form in recent weeks had come under the spotlight but he turned the game around
Cristiano Ronaldo returned to goalscoring form with his first hat-trick of the season and also missed a penalty as Real Madrid extended their lead at the top of La Liga with a 4-1 win at Alaves on Saturday.
Barcelona move up to second, just two points adrift, despite a below-par display in edging past bottom-placed Granada 1-0 thanks to Rafinha's spectacular winner.
Atletico Madrid remain three points back of city rivals Real thanks to doubles from Yannick Carrasco and Kevin Gameiro in a 4-2 win over Malaga despite playing with 10 men for the final half hour.
Ronaldo's wayward form in recent weeks had come under the spotlight -- even drawing whistles from the Santiago Bernabeu crowd last weekend -- but he turned the game around after Deyverson had put Alaves into a shock early lead.
"We are always going to demand goals from Cristiano, but he was good in all aspects," said Madrid boss Zinedine Zidane.
"We knew how to suffer because the first half and the start of the second weren't comfortable or easy.
"But playing like this, if you know how to suffer and then add a bit of movement, we know what we can do."
Real's unbeaten run stretches to 26 matches, but their defensive struggles continued in Vitoria as Zidane's men got off to the worst possible start when Deyverson pounced on an error from goalkeeper Keylor Navas to slot Alaves into a seventh-minute lead.
The visitors needed two slices of fortune to turn the game around before half-time.
Firstly, Deyverson was adjudged to have handled a Gareth Bale free-kick inside his own area and Ronaldo slotted home the penalty.
Ronaldo's second came 16 minutes later when his low effort from outside the area deflected off Zouhair Feddal and flew into the far corner.
The Portuguese missed the chance to seal his hat-trick when his second spot-kick was saved by Fernando Pacheco 12 minutes from time.
However, Alvaro Morata again made his presence felt off the bench as he raced onto Marcelo's through ball and lobbed the onrushing Pacheco for his fourth goal as a substitute this season.
And Marcelo was involved again in the fourth as he and Ronaldo exchanged passes before the latter smashed home two minutes from time.
An injury-ravaged Barcelona named Lionel Messi, Luis Suarez and Neymar in attack against winless Granada, but had to rely on free-scoring midfielder Rafinha in a much closer contest than anticipated at the Camp Nou.
"It is clear it wasn't a brilliant match on our part," admitted Barca boss Luis Enrique.
"Sometimes the players aren't machines."
Rafinha's overhead kick broke the deadlock three minutes into the second-half after Barca toiled to break down Granada's deep-lying defence before the break.
Neymar, Suarez and Messi all missed chances to add a second, but Granada never threatened to end their record of losing in every one of their now 24 visits to the Camp Nou.
Atletico bounced back from their first defeat of the season at Sevilla last weekend, but made life difficult for themselves against Malaga.
Carrasco fired home his sixth goal in his last six games to put Atletico in front before Gameiro took advantage of some slack Malaga defending to double the lead inside 25 minutes.
Sandro Ramirez's stunning free-kick brought Malaga back into the game, but Gameiro restored Atletico's two-goal lead when he latched onto Antoine Griezmann's flick-on to make it 3-1 just before the break.
However, Stefan Savic picked up two quickfire yellow cards to leave Atletico a man short for the final half hour.
Ignacio Camacho headed home from a corner to cut Malaga's deficit once more, but Carrasco showed stunning speed and produced an unerring finish into the far corner to seal the points four minutes from time.
"I think he has improved with a lot of hard work and sacrifice. He has understood his own potential," Atletico boss Diego Simeone said of Carrasco.
"Today he scored a goal with his left foot and then another one on his right on the counter-attack with the finish of a striker."
Sevilla slip to fourth after being held 1-1 at Sporting Gijon.