The failure to cut Real Madrid's six-point lead in El Clasico last weekend made a victory essential at El Sadar.
A goalless first half was followed by a fright as Sergio Leon's clever chip struck the crossbar in the 49th minute, before two well-worked efforts unlocked the solid Osasuna defence, with Jordi Alba providing the final pass each time.
Messi made and finished the third entirely on his own in stoppage-time to wrap up the points on a satisfying afternoon in Pamplona.
Barca coach Luis Enrique said: “It was a complete performance. In the first half we just lacked a goal, but we managed to wear them down. We were superior in all senses."
Luis Enrique underlined that it was almost an obligation to win in order to continue dreaming of catching up Real Madrid: “It's clear that to put pressure on Madrid only winning serves us."