Sevilla had missed the chance to leapfrog Ernesto Valverde's side earlier on Saturday as they were held to a 1-1 draw by Valencia.
Just nine minutes after Messi's opener it was two, the Argentine again playing a vital role as he found Ousmane Dembele out on the left with a wonderful pass, the Frenchman cutting inside onto his right foot and lashing a fierce curling effort into the far corner.
The Barca captain, playing in this fixture for a joint-record 32nd time, beat Diego Lopez with a flawless free-kick from 25 yards that curled away from the goalkeeper's despairing dive.
The second came in the 65th, with the ball a bit further back and from a slightly different angle.
Espanyol started the second period on the front foot, but aside from a Sergi Darder attempt which missed the crossbar, the home supporters did not have too much to shout about.
Messi had also set up Dembele's goal in the 26th, sending a well-placed throughball to the French forward.
Barcelona were caught out at the back in the 74th minute when Duarte stabbed the ball in at close range from a free-kick.
Messi was prevented a hat-trick by a smart Diego Lopez save in the 69th minute, and Espanyol thought that they had registered in the 73rd minute when Duarte converted a Sergio Garcia free kick.
However, following a lengthy review from the Video Assistant Referee, the goal was ruled out for a marginal offside.