Pedro Rodriguez got the other and Raoul Loe got a consolation for Osasuna, who played for more than an hour with ten men after Alejandro Arribas was harshly sent-off after two handball incidents.
Barcelona remain 15 points ahead of Real Madrid in third position and move eleven ahead of Atletico Madrid, who play later on Sunday at Athletic Bilbao.
Osasuna remain in the relegation zone on 18 points, two from safety.
Messi now has 33 goals for the season, 12 more than Cristiano Ronaldo, who earlier on Sunday hit a hat-trick as Real Madrid beat Getafe 4-0.
David Villa started his first league game for Barca in more than two months and former Liverpool player Javier Mascherano filled in for the suspended Gerard Pique in the centre of defence.
Thiago Alcantara was the first to test the highly rated Andres Fernandez in the Osasuna goal on four minutes, but the keeper was quick to block a shot that the midfielder tried to lift over his head from close range.
A long through pass was cleared by Andres only as far as Xavi Hernandez, who found the Argentine in the area. There was still work to do but the four-time winner of the Ballon d'Or produced a beautiful dummy to take him past the keeper before tapping home.
Osasuna levelled the game on 24 minutes against the run of play when Marc Beltran crossed from the right and Loe hit a shot from outside the area.
However, the side from Pamplona were left with ten men only three minutes later when centre-half Arribas received a second yellow card after a shot struck his hand in the area.
Messi coolly slotted away the penalty for his second and Pedro made it three before half-time after a generous pass from Dani Alves left him with a tap in from close range.
The Argentine got his hat-trick on 56 minutes when he started a move in midfield, exchanged passes with Villa, and took the ball around the keeper before slotting home.
And a minute later and it was five and four for Messi as he finished off a swift Barca attack and Adriano pass from close range.
All Real's goals came in a much better second half performance in the derby against Getafe.
It took until 52 minutes for Madrid to find a breakthrough when Sergio Ramos stabbed home from a corner.
Then Ronaldo hit three in ten minutes, his first on 62 minutes after a sweeping counter-attack saw Mesut Ozil play the Portuguese star into space on the left for a crisp finish.
Three minutes later and from similar counter-attacking play he finished off a Gonzalo Higuain cross with a simple header and completed his hat-trick from the penalty spot on after Alberto Lopo had fouled Luka Modric.
Also on Sunday, Rayo Vallecano beat Real Betis 3-0 to move into fifth, a place and a point behind the Seville-based side and a Champions League position.
Piti got the South Madrid side off to a great start from the penalty spot on four minutes before Andrija Delibasic and Jose Carlos added second-half goals to make it five wins in six for Rayo.
Pics: Prabhas, Tamannaah Bhatia at 'Baahubali 2' first look launch at MAMI
'Ae Dil Hai Mushkil' photos: Aishwarya, Anushka, Karan get candid at MAMI
Photos: Huma Qureshi, Neha Dhupia and other celebs at MAMI
Photos: Amy Jackson, Daisy Shah at Mumbai airport
Photos: Sridevi, Irrfan and other celebs at 'Mughal-e-Azam' screening