The Catalan giants managed a slender 2-1 win over their Basque opponents on Sunday night at El Sadar.
Jules Kounde gave Barca the lead from an Ilkay Gundogan corner, before Osasuna equalised on 76 minutes through Chily Avila.
Barcelona, however, turned things around with Robert Lewandowski netting a late winner from the penalty spot.
The victory means Barca are now just two points behind bitter rivals and league leaders Real Madrid, in third.
Though the win was overshadowed by one moment involving youngster Gavi, who picked up a sickening injury following a challenge with Ruben Garcia.
Read more on BARCELONA
Gavi made a tackle with head in Barcelona win and Puyol absolutely loved it
Barcelona star Gavi subjected to crass insults during speech to fans in Madrid
The 19-year-old was caught on camera in pain as blood poured out of his ear.
He was treated by the Barca medical staff, but was barely able to continue due to the extent of the bloodied gash.
The Spain international was given staples, and the club's official X account, formerly known as Twitter, posted a picture of his wound.
Gavi became the youngster player ever to make his 100th Barcelona appearance in the victory.
Most read in Football
Police investigate Keane assault, Sancho hits back, Messi lives up to Hollywood billing
Lionel Messi booed by LA fans in front of Hollywood A-listers and Prince Harry
Police investigating alleged assault on Roy Keane during Arsenal's win over Man United
Kyle Walker: I was close to joining Bayern Munich but will now sign new Man City contract
"It's a dream to reach 100 matches at Barca. I'm so proud," he said post-match.
"We would have lost this game two years ago, it's one of the things we've improved with this coach."
Gavi is now set to link up with Spain and play a part in the Euro 2024 qualifiers against Georgia and Cyprus.