Athletic got off to a dream start in their first match under new coach Marcelino when forward Inaki Williams latched on to a low through ball and raced towards goal, beating one defender before firing low into the net in the third minute.
Barca quickly responded, however, with a sensational team goal, Messi delivering a superb pass to pick out Frenkie de Jong by the byline and the Dutchman volleyed the ball back across the area for 18-year-old Pedri to head home.
Messi and Pedri combined beautifully to put Barca ahead, the youngster receiving a pass from the Argentine before returning it with a delightful backheel and Messi rolled the ball into the bottom corner in the 38th minute.
Messi struck again in the 62nd minute to finish off another brilliant team move and missed a couple of chances to complete his hat-trick, although Iker Muniain made for a tense finale by scoring for Athletic in the 90th.
- READ MORE
- Barcelona reach Copa del Rey final with epic comeback win over Sevilla
- GOAT? Juventus talisman Cristiano Ronaldo's scoring records
- Arsenal manager Arteta speaks on his Barcelona links
- Barcelona, Atletico ordered to further tighten belts by La Liga
- What is Barcagate? All you need to know about Barcelona scandal
- Barcelona CEO and former president Josep Maria Bartomeu arrested
Barca clung on to earn a first win in four matches away to Athletic, having failed to score on their last three trips to San Mames.
The win took Ronald Koeman’s side above Real Sociedad and into third in the standings on 31 points, seven behind leaders Atletico Madrid who have two games in hand on the Catalans.
“When you concede so early it’s normal to drop your heads but we showed a lot of self-belief to make sure that didn’t happen,” said Pedri.
“We knew it was an important game that’s how we approached it, we knew they’d look for Inaki with his speed but we overcame that and got three very important points.”
Athletic forward Williams said his side had played well but were powerless to stop Barca when Messi was on top form.
“We played a good first half, we were the Athletic we wanted to be but we were up against the best player in the world and he swung the game in a different direction,” he said.
“The goals they scored tonight were fantastic and there’s very little you can do to defend against plays like that.”