In the wake of the Catalan government declaring independence, it had been claimed that the match could be postponed, but the fixture went ahead as planned.
Isco sent Real Madrid, who remain eight points behind league leaders Barcelona, ahead in the 12th minute, but second-half goals from Cristhian Stuani and Portu saw Girona beat Los Blancos in their first ever La Liga clash.
Zinedine Zidane made nine changes to the Real Madrid team that started against Fuenlabrada in the Copa del Rey on Thursday night. Kiko Casilla and Achraf Hakimi both kept their spots, but all the big guns were back.
Former Middlesbrough forward Stuani led the line for the home side, but Douglas Luiz, who is also on loan from Man City and impressed against Barcelona earlier this season, started on the bench.
Girona came flying out of the blocks and actually had the first half-chance of the match in the eighth minute when Portu met a dangerous free kick from Aday, but Casilla just about did enough to make it difficult for the number nine.
Maffeo was next to come close for the home side as he hit the post in the 11th minute, but less than 30 seconds later, Real Madrid took the lead as Isco converted from close range after Cristiano Ronaldo's effort had been palmed back into the Girona box by goalkeeper Bono.
Girona continued to force the issue as Borja Garcia hit one from distance in the 21st minute, but Real Madrid were so dangerous on the break, with Ronaldo having one deflected just wide in the 23rd minute, before bringing a smart save from Bono three minutes later.
Karim Benzema fired a decent chance over the Girona crossbar late in the first period as Real Madrid looked for a second, before Girona hit the woodwork for a second time - Portu's header from a brilliant Aday cross catching the inside of the post.
Aday then fired a powerful free kick over the Real Madrid crossbar as Girona continued to search for a leveller, but Isco's goal proved to be the difference at the end of a lively first 45 minutes.
Real Madrid came close to a second early in the second period when Benzema bundled the ball towards goal, but a mixture of Bono and Aday just about managed to clear the danger.
Girona missed a number of chances in the first half, but they were finally level in the 54th minute when Stuani showed excellent feet inside the Real Madrid box before finding the bottom corner with a composed finish.
The home side then incredibly took a 2-1 lead in the 58th minute when Portu converted a Maffeo strike from close range, but it was a controversial goal as the Spaniard appeared to be in an offside position.
Lucas Vazquez and Marco Asensio both came off the Real Madrid bench in the 66th minute, and it was the two full-backs that were replaced as Marcelo and Hakimi left the action, which saw the visitors switch to a back three.
Stuani had a super chance to score his second in the 67th minute after meeting a through pass from Portu, but the striker just missed the far post as Real Madrid played a dangerous game with a three-man defence.
Ronaldo then had a brilliant opportunity down the other end after meeting a free kick from Toni Kroos, but the Portuguese headed straight into the arms of the waiting Bono.
Girona's 2-1 lead remained intact approaching the final five minutes, and despite the intense pressure from Real Madrid, who had a Vazquez effort chalked off for offside, clear opportunities were few and far between.
Some last-ditch defending from Maffeo prevented Ronaldo from having a strike on the Girona goal in the first of four additional minutes at the end of the 90, and the home side closed out the final minutes to record a historic win.