China winger Wu Lei fired home after stepping off the bench midway through the second half to clinch bottom club Espanyol a point in Abelardo Fernandez's first game in charge.
But Barca midfielder Frenkie De Jong's first dismissal of his career, for a second yellow card with 15 minutes left, gave the home side hope and they took full advantage.
The point was enough to lift Barca back to the top of the table, above Real Madrid on goal difference, while Espanyol remain bottom and winless in nine league matches.
Real had briefly leapfrogged Barca into pole position following their 3-0 win at city neighbours Getafe in an earlier kick-off.
Raphael Varane was awarded Real's first-half opener after Getafe goalkeeper David Soria appeared to deflect the ball into his own net when challenged by the France defender.
Varane headed home Toni Kroos' free-kick to double Real's lead early in the second half and Luka Modric added their third in time added on as Zinedine Zidane's side extended their unbeaten league run to 10 matches.
Atletico Madrid remain five points behind rivals Real in third place after securing their fourth-straight win in all competitions with a 2-1 victory over Levante.
All the goals came during a five-minute spell in the first half. Kieran Trippier's cross was turned home by Angel Correa and, although Roger Marti equalised for Levante three minutes later, Felipe headed Atletico back in front.
Correa, Saul Niguez and Joao Felix all threatened to extend Atletico's lead on several occasions, but were denied by Levante goalkeeper Aitor Fernandez.
Eibar defender Paulo Oliveira was sent off in time added on for his second yellow card, while Los Ches have lost only one of their last 12 games in all competitions.