Borja Garcia had sent Girona ahead in the 16th minute of the contest, but penalties from Sergio Ramos and Karim Benzema and a Gareth Bale strike saw Los Blancos take a 3-1 lead with 30 minutes to play.
Benzema then scored his second of the match late on as Los Blancos made it back-to-back La Liga victories under the leadership of new head coach Julen Lopetegui.
Benzema had the ball in the back of the Girona net in the eighth minute of action, but the linesman's offside flag correctly saw the Frenchman's effort chalked off.
Less than two minutes later, Girona took the lead. A low cross from Anthony Lozano was deflected into the path of Borja Garcia, and the number 10 found the top corner with a stunning effort.
Real Madrid had a lot of the ball in the period that followed, but Girona continued to threaten down the other end, and Dani Carvajal just managed to prevent Garcia from tapping home a Portu cross in the 26th minute.
Marcelo struck over the Girona crossbar in the 30th minute, before Ramos headed wide from close range moments later as Los Blancos looked for a leveller in Catalonia.
Ramos remained Madrid's biggest threat, and it was the captain that levelled the scores from the penalty spot in the 39th minute after Asensio had been brought to the ground by Marc Muniesa.
Bale had a half-chance to send Real Madrid ahead in the final stages of the first period, but the Welshman's effort from a narrowing angle was saved by Girona goalkeeper Bono.
Bale also had the first shot of the second half, but the attacker's attempt from a wide position was wild.
Madrid did take the lead in the 52nd minute, however, when Benzema slotted home from the penalty spot.
Indeed, the visitors gained their second spot kick of the match when Pere Pons clumsily brought Asensio to the deck, and Benzema stepped forward to find the bottom corner of the net.
Lozano headed into the arms of Keylor Navas in the 57th minute as Girona looked for their second of the match during a period where both teams were committing players in the final third of the field.
Another goal was always likely due to the open nature of the match, and it came for Real Madrid just before the hour when Bale raced away from Muniesa before finding the bottom corner with a super finish.
Navas had to keep out a close-range Portu effort 15 minutes from time, but Madrid had their fourth in the 80th minute when Benzema collected a low cross from Bale before firing home.
Both teams had half-chances - including a powerful strike from Alex Granell which Navas kept out - to add to the scoring late on, but it finished 4-1 as the European champions moved onto six points from an available six at the start of the 2018-19 campaign.
GIRONA (4-3-3): Bono; Porro (Aday 79'), Bernardo, Juanpe, Muniesa; Timor, Pons (A Garcia 71'), Granell; B Garcia, Lozano (Stuani 58'), Portu
REAL MADRID (4-3-3): Navas; Carvajal, Nacho, Ramos, Marcelo (Varane 60'); Casemiro, Kroos, Isco (Modric 77'); Asensio, Bale (Lucas 87'), Benzema