CSKA Moscow handed Real Madrid its worst ever European home loss and got nothing in reward.
CSKA beat Madrid 3-0 on Wednesday for its second straight win over the defending Champions League holders, but it still finished in last place in their group and missed out on a Europa League spot.
The Russian team finished behind Viktoria Plzen, which defeated Roma 2-1. CSKA need to better Plzen's result in the Czech Republic to finish third, with both teams already out of contention for the Champions League knockout stage.
"It's sad to say the least to beat Real Madrid, earn seven points, but finish bottom and get eliminated from Europe," CSKA coach Viktor Goncharenko said.
"But we only have ourselves to blame. In any case, we've made sure we'll spend the holidays in a great mood after tonight's win."
CSKA finished with the same seven points as Viktoria Plzen but lost on the head-to-head tiebreaker. Madrid finished with 12 points, three more than Roma. FC Copenhagen was the last team to finish last in its group with seven points, back in 2006.
CSKA's 1-0 home win over Real Madrid in October was the team's only other group victory. The Spanish club was still coached by Julen Lopetegui at the time.
Real Madrid rested most of its regular starters after already clinching the group win, but it still made for a memorable victory for the visitors at Santiago Bernabeu Stadium with goals from Fedor Chalov and Georgi Schennikov late in the first half, before Arnor Sigurdsson added another in the second.
Real Madrid left the field jeered by its fans, with many leaving after CSKA scored the third goal.
"The fans will jeer when they are not happy with the result," Madrid coach Santiago Solari said.
"It's not the result we wanted but we were able to rest some players and give more playing time to the youngsters."
With the Club World Cup only a week away, Solari used several players who hadn't started much this season, including Francisco "Isco" Alarcon and Marco Asensio.
Isco was jeered during most of the second half and appeared to argue with some of the fans in the stands.
Three players were making their Champions League debut, including young Brazilian forward Vinicius Junior, midfielder Federico Valverde and central defender Javier Sanchez. Karim Benzema and Marcelo were the only veterans in the starting lineup, with Toni Kroos, Raphael Varane, Luka Modric and Gareth Bale beginning on the bench.
Madrid controlled the game early, with Vinicius Junior threatening down the left flank and Marco Asensio making good runs on the right. The Brazilian nearly scored from inside the area midway through the first half, and Asensio struck the crossbar with a long-range shot a few minutes later.
CSKA was dangerous on counterattacks and it took advantage of Madrid's vulnerability on defense to open the scoring with Chalov's well-placed left-footed shot into the far corner in the 37th minute.
Schennikov added to the lead six minutes later from close range after Madrid goalkeeper Thibaut Courtois partially saved a shot by Mario Fernandes inside the area. Chalov helped set up the goal with a back-heel pass to Fernandes.
Bale replaced Benzema at halftime and Kroos entered the match in the 58th, but they were not able help Madrid improve much.
Sigurdsson sealed CSKA's victory with a low shot from inside the area in the 73rd. Madrid hosts Rayo Vallecano on Saturday before travelling to the United Arab Emirates for its debut in FIFA's Club World Cup on Dec. 19.