The Argentina forward scored Barca's third goal when he collected Pedri's backheel and struck the ball past goalkeeper Jordi Masip on 65 minutes.
Messi had equalled Pele on Saturday in a 2-2 draw with Valencia.
The two men scored at almost an equal rate for their clubs.
It was the 33-year-old Argentine's 749th competitive match for Barca, meaning he has scored a goal every 1.16 games.
The Brazilian scored 643 goals in 757 matches with Santos, where he played 1956 to 1974, or one every 1.17 matches.
Messi, a six-time Golden Ball and six-time Golden Shoe winner, is by far the highest scorer in Barca history (Cesar Rodriguez is next on 230 goals), the highest scorer in the history of the Spanish Championship (451 goals, ahead of Cristiano Ronaldo's 311), and the player who has won the most trophies with the Catalan club (34, including four Champions Leagues).