The Portugal international scored his side's only goal of the game with a header, before Antoine Griezmann equalised late on.
But, after a nasty collision with Toni Kroos, he struggled to continue, and was eventually forced off in the 67th minute with Nacho replacing him.
After undergoing medical tests, Madrid later confirmed a double rib break.
"After the examinations carried out today on Pepe at the Sanitas La Moraleja University Hospital, he has been diagnosed with fractures in seventh and eighth ribs on the left side," a statement from the club explained.
Pepe's absence gives Zinedine Zidane a fresh defensive headache.
Raphael Varane is already on the casualty list with a hamstring problem that is expected to keep him out of action for up to a month, leaving Sergio Ramos and Nacho as the coach's only front-line centre-backs as a crunch Champions League quarter-final against Bayern Munich looms Wednesday.
The Portugal defender sustained a rib injury two years ago and missed just over a month. However, those were bruised ribs, rather than broken, so he likely faces a longer spell on the sidelines for a Madrid side battling on two fronts - trying to hold on for a La Liga title while also aiming to take home Champions League glory.
Even if he recovers as quickly as he did in 2015, that would still leave the centre-back unavailable for the Clasico against Barcelona on April 23 and puts the remainder of his season in doubt.
The 34-year-old's contract expires June 30, so it is possible Pepe may have played his last game for los Blancos.