Medical staff taped up the affected area but it quickly became clear the Real captain would be unable to continue and he was replaced by Diego Lopez.
Coach Carlo Ancelotti said that he hoped Casillas would recover in three to four days but Spanish media reported the 32-year-old could be sidelined for two weeks.
"Iker had bad luck, that happens in football," said Real's hat-trick hero Cristiano Ronaldo.
"He did something to his ribs. He was down in the dumps but he will recover soon."
Casillas has barely played since Real and Spain team-mate Alvaro Arbeloa accidentally kicked his hand during a Copa del Rey match in January and broke a bone.
He fell out with former coach Jose Mourinho on his return and was replaced in the team by Lopez.
Mourinho's successor Ancelotti has used Lopez in Real's four La Liga matches this season but picked Casillas, who has retained his place in the Spain team, for their opening Champions League game.
Spain coach Vicente del Bosque has stood by his captain and if fit he will almost certainly be first choice for the final two World Cup qualifiers at home to Belarus and Georgia on October 11 and October 15 respectively.
The world and European champions are level on 14 points with France at the top of Group I and have a game in hand.
- Sports & Recreation
- Carlo Ancelotti