Messi was named on the Barcelona bench for the first time since September 2019, having played every minute of Barcelona's last 37 games, and was brought on for the second half with the sides level at 1-1 after goals from Ousmane Dembele and Antonio Sanabria.
- ESPN Insider Notebook: Possible Solskjaer replacements
The Argentina international quickly set up a goal for Antoine Griezmann and then scored a penalty before Lorenzo Moron pulled one back for Real Betis. However, Messi had more in the tank and scored his first non-penalty goal of the season. Pedri added a fifth to ensure a Barcelona win.
Dembele opened the scoring with a powerful left-footed shot past Claudio Bravo on 22 minutes.
Griezmann had the chance to double Barcelona's lead on 32 minutes when Ansu Fati was brought down in the box and a penalty was awarded. However, he didn't get the ball far enough away from Bravo who was able to get a hand to it.
The missed penalty was Griezmann's fourth in a row for both club and country.
"I hope Griezmann keeps working hard as he did today," Barcelona manager Ronald Koeman said after the game. "To miss chances you have to be in the right place. I have to praise his character, because he's always there, even after misses. And he knows perfectly that he's missed a penalty and other chances. But the important thing is that he's always there and that character he shows is important."
Real Betis jumped on the opportunity to draw level two minutes into added time at the end of the first half. Cristian Tello drifted a ball into the box which Gerard Pique failed to clear and the ball landed in front of Sanabria who scored from 10 yards out.
Messi replaced Fati at half-time and made an immediate impact, setting up Griezmann for Barcelona's second goal on 49 minutes.
Koeman later confirmed that Fati suffered an injury in the first half which was why he was substituted at such an early point.
Messi scored Barcelona's third on 61 minutes when VAR adjudicated that Aissa Mandi had handled the ball in the box. Mandi was shown a red card for his infringement.
Moron pulled a goal back for Real Betis on 73 minutes with a right-footed shot from eight yards out after a pass in from Alex Moreno.
A one-two with Sergi Roberto set Messi up for his second goal on 82 minutes.
He nearly had his hat trick three minutes later but the goal was disallowed for offside.
Pedri was on hand though to add Barcelona's fifth on 90 minutes after another assist from Roberto.
"An important win due to the need for three points," Koeman said. "I'm happy because we created a lot of chances and we took them in the second half. We didn't in the first half and 1-1 at the break wasn't fair. It was a deserved win overall -- and we deserved to score even more goals.
"I've been speaking with Messi since yesterday. He ended the game against Dynamo Kiev with a minor problem and wasn't in condition to play from the start. We put him on the bench ... but if he doesn't have any problems, he always plays from the start."