Messi gave Barca an early lead with the help of a pin-point pass from Sergio Busquets but Getafe pulled level with an own goal by Clement Lenglet.
The visitors then conceded a calamitous own goal when Sofian Chakla’s backpass deceived keeper David Soria and trickled over the line.
Messi extended Barca’s lead before halftime, hitting the post then following up to net from a tight angle and to move on to 25 La Liga goals for the 12th season in a row.
But the Catalans slowed down in the second half and Turkish forward Enes Unal made for an exciting finish by converting a penalty in the 69th minute following a VAR review for a foul by Ronald Araujo.
Getafe had a couple of half-chances to level but Uruguayan defender Araujo made amends for his foul on Unal by heading in Messi’s corner in the 87th minute to effectively kill the game.
🎙 @RonaldKoeman breaks down the 5-2 win over Getafe https://t.co/VK1RyhrUxl
— FC Barcelona (@FCBarcelona) 1619134264000
Barca earned a penalty in added time but Messi surrendered the chance to score a hat-trick and handed the ball to Antoine Griezmann who slammed in the spot-kick.
The win took Barca back up to third place on 68 points, five behind leaders Atletico Madrid but with a game in hand.
“It was a very strange game but the team knew how to get the job done and win which is the important thing,” said Araujo.
“We suffered a little bit in the second half, we could have been more comfortable. Every game we have left is like a final and every team will give everything.”
1️⃣2️⃣ straight seasons with 25+ goals in @LaLigaEN! 🐐 https://t.co/3YkUQDE5kV
— FC Barcelona (@FCBarcelona) 1619139605000
Getafe gave Koeman’s side a guard of honour for their recent Copa del Rey triumph but the visitors also wore T-shirts saying “Earn It”, criticising Barcelona’s decision to sign up to the breakaway European Super League.
“The news had a big impact on me, any clubs want to compete in Europe and we want to earn it on the pitch,” said Getafe’s Angel Rodriguez.
“We’re a humble club who played in the Europa League so obviously I’m totally against it.”