The visitors gave their city rivals a tough game at the Camp Nou, but Messi's chipped free-kick over the wall from 19 yards and a late second kept the reigning champions 10 points clear of second-placed Atletico Madrid, who thrashed Alaves 4-0.
Messi has now netted eight times in his last four games for Barca, and leads the way in the La Liga scoring charts with 31 goals, 13 ahead of teammate Luis Suarez.
"I had no idea he would hit (the free-kick) like that," said Barcelona coach Ernesto Valverde.
"I would love to say that we had planned it, but it's not true, it's up to him. He didn't need my opinion and he scored."
It was a fitting way for the Argentinian to mark his 675th Barcelona appearance, which moved him ahead of Andres Iniesta into second on the club's all-time list — 102 adrift of Xavi Hernandez.
He made a low-key return to international action in midweek as Argentina lost a friendly to Venezuela, but Valverde was delighted it did not affect Messi on Saturday.
"Messi is the same player no matter what team he is playing in," he said. "He would be the same if he played in Australia... We are delighted to have him, it's a luxury for me to coach him."
Barca struggled to break down Espanyol early on, with Messi, Suarez and Ivan Rakitic all wasting half-chances in the first period.
Barcelona saw a penalty appeal waved away by both the referee and VAR on the stroke of half-time, and Malcom was denied just after the hour mark by away goalkeeper Diego Lopez as the Catalan giants grew frustrated.
But Messi has been consistently unplayable this season, and he dinked in a wonderful effort from a set-piece despite Victor Sanchez's best efforts to clear off the line.
The three points were sealed in the 89th minute as Malcom ran clear on the breakaway, before cutting the ball across for Messi to sweep a trademark finish low into the bottom corner.
Barcelona next visit Villarreal on Tuesday with a second successive title looking even more like a mere formality.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ