The defeat was a costly one for Real as they have slipped nine points behind La Liga leaders Barcelona in the table while Atletico Madrid are also two points ahead of them in second. Marcelo also had a goal chalked off for offside at the end of the first half as Real Madrid controlled the match.
Both teams started brightly with Girona providing as much threat on the counter as Real were in possession, but the first opportunity went to the home side with Lucas Vazquez seeing a shot blocked by Bono having advanced into the penalty area.
TALKING POINT - Have Real Madrid's title hopes been vanquished once and for all?
Girona manager Eusebio Sacristan said: "It's really important for us to win at the Bernabeu - for our fans, for our team".
Inter were forced to battle in his absence, with all three goals coming in a five-minute spell deep into the second half. He was the one who did the most damage to Real Madrid. Portu hit the crossbar and then scored a 74th-minute victor to severely dent Real's hopes of becoming Spanish champions this season.
Casemiro teed up worldwide team-mate Marcelo for a drilled finish before the break, but the goal was rightly ruled out for offside. Courtois could only push Lozano's header back into the danger zone but Garcia blazed the rebound way over the crossbar.
Today's defeat to Girona is already Madrid's seventh in the league this term - and Santiago Solari's men are looking lacklustre. Real Madrid have failed to make the most of their chances and Girona have now made the most of that.
Ramos was dismissed in the last minute of Sunday's 2-1 victory for relegation-threatened Girona at the Santiago Bernabeu. "We came from many hard matches that we have overcome and it may be that it took its toll in the second half".
Lozano's right-footed curler was parried away by Courtois but Portu - who had struck the post moments earlier - was perfectly placed to force a header inside the near post from six yards out.
Meanwhile, top scorer Mauro Icardi watched from the stands as Internazionale strengthened their grip on third place in Serie A with a hard-fought 2-1 win over Sampdoria at San Siro.
Real Madrid missed the chance to go second in La Liga as Girona came from behind to record a surprise away win. He'll miss the Clasico now!
Sergio Ramos has been sent off 19 times in La Liga, more times than any other player in La Liga history.