Dani Ceballos scored with a minute remaining to keep Real Madrid's perfect Champions League record intact this season, winning 3-2 at Union Berlin on Tuesday.

Madrid came into the match guaranteed of first place in their group but fell behind just before half-time, Union striker Kevin Volland scoring on the counter after Luca Modric had a penalty saved. 

Already eliminated from the Champions League, Union needed to win to keep their Europa League hopes alive but conceded two Joselu goals in ten minutes, silencing the Berlin Olympic Stadium crowd. 

Alex Kral gave the home side hope late, scoring Union's second just after coming on, but Real regained the lead moments later, Dani Ceballos' deflected shot dribbling into the net late on.

Madrid coach Carlo Ancelotti reflected on the "slightly unusual match" saying his side had the game "well controlled for 40 minutes and then two mad minutes made it complicated for us."

Home coach Nenad Bjelica said "Real Madrid make you run a lot, until you're running on empty -- but that also happens to better teams than Union Berlin."

As they did in Madrid and in Berlin against Braga, Union conceded a late goal to drop points. Bjelica said "there's been a lot of bad luck there."

"We'll try and learn from that and do better."

The loss means Union's first Champions League campaign, in just their fourth season in the top division, comes to an end with two draws and four defeats. 

Modric misses penalty

Bjelica, in the Union dugout for just the fourth time, praised Jude Bellingham before the match, but said countryman Modric was "still the best in the world."

Bellingham, who at 20 is almost half the age of the 38-year-old Croatian veteran, shone early, forcing a save from Frederik Ronnow and shooting just wide of the post moments later. 

The 14-time Champions League winners were a class above the debutants in the opening stages, bossing possession and field position despite coach Carlo Ancelotti making five pre-match changes. 

Union held on until a clumsy handball from Diego Leite brought Modric to the spot in the shadows of half-time.  

Diving to his right, Ronnow got a boot to the low strike, his third penalty save from five attempts in all competitions this season. 

The Denmark 'keeper lofted the ball forward, Kevin Behrens finding his namesake Volland, who put Union in front after a mistake from David Alaba. 

Madrid's experience showed, the visitors remaining calm and continuing to dominate possession, Joselu heading in a perfect Rodrygo cross 15 minutes into the second-half.

The Madrid striker doubled up ten minutes later, again scoring with his head from an even tighter angle to snatch the lead. 

"We had more width in the second-half" said Madrid boss Ancelotti, "when you have a player like Joselu, who is excellent in the air, you have to use that strength."

The Germany-born Joselu, who made his debut for Spain in March at the age of 33, now has eight goals in 21 matches since moving to Madrid on loan from Espanyol in the summer. 

Kral's late strike gave Union hope of keeping their unbeaten record alive under Bjelica, but Bellingham found Ceballos to score on the break.