Barca should have killed the game off in the first half as Luis
Suarez and Messi missed two big chances each against La Liga's bottom side.
However, Suarez rounded off a fine team move to break the deadlock just before the hour before Messi's double in the final 17 minutes moved him ahead of Cristiano Ronaldo as La Liga's top scorer with 11 for the season.
Real can extend their lead once more and set a new club record unbeaten run of 35 games when they host Deportivo la Coruna later on Saturday.
"We are Barcelona and we know we can never give up," Suarez told BeIN Sports Spain.
"We are candidates to win the league, it doesn't matter if we are four, five, six or seven points behind, we won't give up."
Barca were in desperate need of a lift after conceding in the last minute to Real in last weekend's El Clasico.
The Catalans' upturn in performance since captain Andres Iniesta's return from a six-week injury layoff continued in the first half at Osasuna, but Barca were in danger of paying for their profligacy in front of goal.
A brilliant pass from Messi freed Suarez inside the area just eight minutes in, but the Uruguayan pulled his shot inches wide of the far post.
Suarez then hit the woodwork as he spun inside the area.Osasuna remain five points off safety and it was easy to see why they are still without a home win all season as the hosts were opened up at will.
Suarez turned provider for Messi, but Nauzet Perez rushed from his goal to block.
And the goalkeeper frustrated the five-time World Player of the Year again moments later by just raising a hand in time to divert Messi's attempted chip behind.
"We were patient and generated a lot of chances," said Barca boss Luis Enrique.
"It was key to go in front and calm ourselves down.
"The goals came in the second-half, but we deserved to go in front in the first-half and have a much easier game."
Osasuna briefly threatened to cause a huge upset either side of half time as firstly Oriol Riera just couldn't stretch to tap home a dangerous cross at the back post.
Sergio Leon then gave Barca a scare when his brilliant lob over Marc-Andre ter Stegen came back off the underside of the bar.
Barca created fewer chances in the second half, but were more clinical.
Sergio Busquets and Messi combined to release Jordi Alba on the left and his low cross was rolled into an unguarded net by Suarez despite Osasuna calls for offside.
The second goal came about in similar fashion 13 minutes later as Alba again got to the by-line and his cross was volleyed home by Messi at the near post.
And Messi didn't need any help for his second in stoppage time as he wriggled clear of three Osasuna defenders and left Perez on the floor before lifting the ball high into the net.