Man City and PSG also booked their last-16 places, while AC Milan kept their hopes alive in style.
First-half goals from David Alaba and Toni Kroos and a Karim Benzema strike earned Real a 3-0 win at Sheriff Tiraspol that secured their place in the next stage.
Earlier Edin Dzeko’s second-half double earned Inter a 2-0 win over Shakhtar Donetsk.
Real have a two-point lead over Inter ahead of the two clubs’ meeting on matchday six when the group winners will be decided, while Moldova’s Sheriff head to the Europa League.
Manchester City and Paris St Germain both secured qualification from Group A after Pep Guardiola’s side came from behind to beat the Ligue 1 leaders 2-1 in Group A.
Kylian Mbappe put PSG ahead just after half-time at the Etihad Stadium but goals from Raheem Sterling and Gabriel Jesus turned the game on its head and saw City secure top spot.
Both teams are through after RB Leipzig won 5-0 at Club Brugge to boost their hopes of reaching the Europa League. Christopher Nkunku opened and closed the scoring in Belgium, while Emil Forsberg also netted a double, the first from the penalty spot, and Andre Silva was also on the scoresheet.
AC Milan recorded their first Champions League victory since the 2013-14 season as a 1-0 win over Atletico Madrid kept alive their hopes of progression.
Junior Messias’ headed an 87th-minute winner in Madrid to leave an exciting finale to Group B.
Liverpool have already won the group, and made it five wins from five with a 2-0 win against Porto at Anfield with second-half goals from Thiago and Mohamed Salah.
But the results leave Porto, Milan and Atletico all separated by one point heading into the final round.
Ajax maintained their 100 per cent record in Group C with a 2-1 victory at Besiktas, who led through Rachid Ghezzal’s 22nd-minute penalty.
Egter, substitute Sebastien Haller’s double after the break saw the Dutch club notch a fifth group win.
Sporting Lisbon are in pole position to follow Ajax through after they moved above Borussia Dortmund into second with a 3-1 win against the Bundesliga side.
Pedro Goncalves’ brace gave the hosts a two-goal cushion before their task was made easier by Emre Can’s 74th-minute red card. Pedro Porro headed the third before Donyell Malen’s late consolation goal in added time.