Messi's goal in the second period of relegation injury threatened Mallorca - with his right foot, not favored on the left - meant that the Argentine had become the first player to score at least 20 goals in 12 consecutive La Liga seasons.
He also produced two assists in the 4-0 victory that put Barcelona five points ahead of rival Real Madrid at the top of the table.
Messi and Barcelona had not played for more than three months in the midst of the coronavirus pandemic, Spain being one of the most affected countries in the world.
But that didn't stop a man wearing an Argentina Messi jersey from stepping onto the pitch on Saturday to try to get a picture with the Ballon d'Or winner's record six times. He was intercepted by security and escorted.
Arturo Vidal opened the scoring for Barcelona in the second minute after converting the perfect cross from Jordi Alba and Messi passed Alba to the 79th.
Barcelona's other goal came from Martin Braithwaite, who was signed as Modeste Leganes' emergency striker in February after long-term injuries to Ousmane Dembele and Luis Suarez - who returned on Saturday and helped Messi's efforts .
Brathwaite clung to a ball in the box and made a shot in the roof of the net in the 37th minute for his first goal at Barcelona.
'It's incredible'
"I've been waiting for this for a long time," said Braithwaite on Barcelona television. "It was amazing to score my first goal and, most importantly, it was very important to start as we did today.
"I worked a lot during this break and I can't wait to play this game and I hope to have a goal. I'm happy, really happy."
Barcelona host the penultimate Leganes on Tuesday before an apparently more difficult test in third place in Seville on Friday.
He is aiming for a third consecutive league title in an eventful season.
"It is true that we need to improve, but I am really satisfied with the performance of the team after so long," said Barcelona manager Quique Setien, who replaced Ernesto Valverde who was laid off in January.
Real Madrid welcome another team in danger of relegation, Eibar, on Sunday.
