Croatian striker Ante Budimir slipped past Barcelona’s defense to head in Bryan Zaragoza’s cross from close range after 18 minutes.
Zaragoza doubled Osasuna’s lead by breaking through on goal and calmly slotting past goalkeeper Inaki Pena.
Barcelona pulled one back after the break when Pau Victor’s shot slipped through goalkeeper Sergio Herrera’s hands and into the net.
However, Budimir restored Osasuna’s two-goal cushion by converting a penalty he earned after being brought down by Sergi Dominguez in the box.
Abel Bretones added to the scoreline with a powerful strike from the edge of the area, finding the bottom right corner with five minutes remaining.
Lamine Yamal grabbed a late goal for Barcelona with a brilliant finish into the top corner, but it was too little, too late for the visitors.
The loss ends Barcelona’s perfect start to the La Liga season, where they had won their first seven matches. Real Madrid can close the gap to just one point with a victory over Atletico Madrid on Sunday (20:00 BST).
Barcelona will now shift their focus to the Champions League, where they host Young Boys on Tuesday (20:00 BST), aiming to recover from their opening defeat to Monaco.