Nolito fired the hosts into an early lead before goals from Toni Kroos and Hernandez turned the game around.
Santi Mina brought Celta level, but James Rodriguez's deflected effort put Madrid in front once more before the break and Hernandez rounded off the scoring in style 22 minutes from time.
"It was the kind of game we like," said Real boss Carlo Ancelotti.
"To play on the front foot and take risks as did Celta. That made for a spectacular and very open game.
"Hernandez is enjoying his moment and helping the team a lot. The whole team worked very hard. We struggled in many moments during the game, but up front we were very efficient."
Hernandez had starred with the only goal of the tie as Real beat Atletico Madrid for the first time in eight meetings this season to reach the Champions League semi-finals in midweek.
However, they were pushed onto the back foot straight away by a Celta side that had already claimed the scalps of Barcelona and Atletico in La Liga this season.
Nolito opened the scoring after just nine minutes as he eased past the weak challenges of Dani Carvajal and Asier Illarramendi before leaving Iker Casillas flat-footed with a low shot that rolled in at the near post.
Celta's lead lasted only seven minutes as Cristiano Ronaldo's dangerous cross from the right was cleared only as far as Kroos at the edge of the area and the German curled home just his second goal for Madrid.
The visitors then went in front as Hernandez's scoring streak continued with a fine low finish after a neat one-two with Rodriguez.
Yet, again the lead was short-lived when Fabio Orellana's through ball split the Madrid defence wide open and Mina slotted into an empty net at the second attempt after his initial effort came back off the post.
Celta's offensive approach was allowing Madrid plenty of space to counter-attack and Ronaldo nearly took advantage of another lightning break when he struck the post from Hernandez's pass.
However, Ancelotti's men only had seconds to wait for the third goal to arrive and there was a touch of fortune about it as Rodriguez's shot was deflected past the helpless Sergio Alvarez.
Celta began the second period with the same intensity as they had the first and the home fans were screaming for a penalty when Orellana tumbled inside the area under pressure from Kroos, but the referee was unmoved.
Hernandez then sealed the three points in stunning fashion as he controlled Sergio Ramos's brilliant ball over the top before slamming past Alvarez for his fourth goal in as many games.
Earlier, Europa League holders Sevilla maintained their push for a return to the Champions League with a comfortable 2-0 win over Rayo Vallecano on Sunday.
Unai Emery's men had edged out Zenit St Petersburg in a gruelling 90 minutes to make it back to the semi-finals of the Europa League with a 2-2 draw in Russia on Thursday.
However, they showed little sign of fatigue in a commanding first 45 minutes and made the game safe before the break thanks to goals from Vicente Iborra and Daniel Carrico.
Victory moves the Andalusians a point above Valencia in the fight for a top four finish, although Los Che can move back into the final Champions League place should they avoid defeat at home to Granada on Monday.
At the other end of the table, Almeria gave their hopes of survival a huge boost with a 2-0 win over fellow strugglers Eibar thanks to goals from Thievy Bifouma and Verza.
That result elevated Almeria out of the relegation zone at Deportivo la Coruna's expense after they had earlier claimed a point in a 1-1 draw away to Malaga.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ