Despite dominating large parts of the first half, Barca found themselves a goal down at the break courtesy of a volley from Joseba Llorente in the 17th minute.
However, it was Osasuna who should have added to their tally with 70 minutes played. Substitute Nino found himself with just Victor Valdes to beat, but he sent his effort wide via the upright.
Barca eventually grabbed the equaliser with 76 minutes played when Alexis Sanchez squared the ball for a stretching Messi, who slotted the ball into the net. In the aftermath of that goal, Osasuna's Francisco Punal was handed his marching orders for the level of his protest.
The away side made their numerical advantage count ten minutes from time as Messi sent the ball into the bottom corner of the net following a pass from full-back Jordi Alba.
Osasuna pushed hard for an equaliser in the closing stages, but Barca held firm.