Messi also finally got his first assist of the season when he picked out defender Clement Lenglet with a splendid cross and the Frenchman rose to head Barca in front after 21 minutes.
The Argentine also had a hand in the visitors’ second goal, laying on a pass for right back Sergino Dest to latch on to down the right flank and play a cross into the path of Martin Braithwaite, who slid in to score in the 35th minute.
Messi capped a brilliant individual display with a splendid goal midway through the second half, running in behind to meet a pass from teenager Pedri and slotting into the far bottom corner to eclipse Pele’s long-standing scoring mark for Santos.
It was also an outstanding team display from Ronald Koeman’s side, who responded to Saturday’s disappointing 2-2 home draw against Valencia by earning their first away league win since beating Celta Vigo on Oct 1.
Barca remain fifth in the standings, moving on to 24 points after 14 games. Atletico Madrid are top with 32 points from 13 games after a 2-0 win at Real Sociedad on Tuesday.
“Today was a very complete performance. We needed to win this game and we did that while showing some real quality,” said Barca scorer Lenglet.
“Today our tactics worked well and we’re very happy. Our fullbacks were able to play high up the pitch and it was a consistent performance overall, while we didn’t let our opponents have too many chances.”
Messi, who remarked earlier this week that he sometimes struggled to get motivated for games in the absence of fans, looked up for the match from the first whistle.
The 33-year-old nearly gave Barca an early lead when he rattled a shot towards the top corner only to be thwarted by a save from keeper Jordi Masip.
He dictated Barca’s play throughout the game with some brilliant passing and movement, while he almost scored a second goal in added time when he raced through on goal but fired against the post from a tight angle.