Real leapfrogged Barcelona back to the summit with eight games remaining but were made to fight after Karim Benzema's outrageous back heel had set up Casemiro's decisive strike on the stroke of half-time.
Espanyol created a string of chances to make it an anxious night for Zinedine Zidane's side, who were also wasteful in front of goal.
But Antonio Conte's side hit back through Stefan de Vrij (84) and Alessandro Bastoni (87) to clinch three vital points, while Parma's Juraj Kucka was shown a straight red card for his reaction off-the-ball following Inter's equaliser.
Atalanta remain on course for a top-four finish after notching their sixth straight league win, 3-2 at Udinese.
Brazilian defender Rogerio struck a stoppage-time equaliser for Sassuolo in a 3-3 home draw with Hellas Verona and Sampdoria remain in a relegation dogfight after slipping to a third straight defeat, 2-1 at home to Bologna.
In Germany, Stuttgart bounced back to the Bundesliga at the first attempt as they secured the runners-up spot as expected in the second tier, despite a 3-1 home defeat to Darmstadt. Stuttgart finished three points clear of third-placed FC Heidenheim, who lost to 3-0 to champions Arminia Bielefeld but had no realistic chance of catching Stuttgart due to goal difference.
Stuttgart's former Germany international Mario Gomez, 34, scored his side's goal and later confirmed it was likely to be his final match before he retires as a player.
Hamburg missed out on the play-offs and must spend a third season in Bundesliga 2 after they crashed to a 5-1 home defeat to Sandhausen in their final match.
Hamburg needed to better the result of Heidenheim, who now go into a play-off again the Bundesliga's third-last placed team, Werder Bremen, for next season's final top-tier berth.
On the last day of the Bundesliga on Saturday, Bayern Munich were crowned champions again, a 4-0 win at Wolfsburg leaving them 13 points clear of Borussia Dortmund.
RB Leipzig and Borussia Monchengladbach claimed the final two Champions League spots, while Fortuna Dusseldorf and Paderborn were relegated.