Barcelona needed a late header from Gerard Pique to earn a 1-1 draw at city rivals Espanyol on Sunday – and a new club record.

Gerard Moreno threatened a LaLiga upset at a soggy RCDE Stadium when he opened the scoring midway through the second half with a header from substitute Sergio Garcia’s cross.

However, central defender Pique headed home an 82nd-minute Lionel Messi free-kick to stretch the runaway leaders’ unbeaten start to the season to 22 games, the best run in the club’s history.

Philippe Coutinho hit the bar in the 22nd minute for Barca, who are now within 10 matches of equalling the national record – set by Real Sociedad in 1979-80.

In the day’s early kick-off Getafe extended their unbeaten home run but were unable to claim victory over Leganes as the two local rivals played out a goalless draw on the outskirts of Madrid.

The hosts hit the woodwork twice in four minutes at the start of the second half, Vitorino Antunes striking the post with a free-kick and Jorge Molina heading against the crossbar, but they could find no way through.

The result means Getafe are now unbeaten in their last eight matches at the Coliseum Alfonso Perez, winning five.