Barcelona moved seven points clear at the top of La Liga after Dani Olmo and Robert Lewandowski struck late against Espanyol.
Hansi Flick’s side were frustrated until four minutes from time when Fermin Lopez set up his fellow substitutes to score the crucial goals.
First he played in Olmo to curl a superb strike into the top corner, before more good work by Lopez on the right teed up Lewandowski for a delightful close-range finish in the 90th minute.
Barcelona have scored 12 goals in the last 15 minutes of the second half, more than any other team in La Liga this season.
In a lively Catalan derby, the hosts made a fast start with former Blackburn Rovers forward Tyrhys Dolan having a shot blocked after four minutes.
And it was visiting keeper Joan Garcia who returned to haunt his former club, with the 24-year-old – who left Espanyol last summer after nine years – making a string of vital saves.
His replacement Marko Dmitrovic made a crucial stop in the 72nd minute to deny Eric Garcia from close range and a draw looked likely until Barca’s late pressure paid off.
Second-placed Real Madrid could reduce the gap at the top to four points if they beat Real Betis at home on Sunday (15:15 GMT).
Espanyol, whose last win over their neighbours in the league was back in 2009, remain in fifth place.