An early goal for Osasuna and a red card for Robert Lewandowski looked to have cornered Barcelona, with a red card for on-the-bench Gerard Pique in his final match of his club career only adding insult to injury.
Here is ESPN's Sam Marsden with reaction and analysis from Estadio El Sadar.
1. 10-man Barca dig deep for biggest win of the season
It is no exaggeration to say this was perhaps Barcelona's biggest win of the season so far.
Given how the game developed, they would have happily taken a point from Tuesday's game at Osasuna until Raphinha's late header unexpectedly gave them three. Makeshift centre-back Frenkie de Jong picked out the run of the Brazilian in the 85th minute and he produced a brilliant finish to score just his second goal of the season the day after he bemoaned his lack of goals since joining from Leeds United.
An hour earlier, it had not looked good for Barca. They made a slow start, Sergio Busquets was sloppy on a corner kick and they conceded. Then Robert Lewandowski was silly and they were too easily wound up by refereeing decisions that they felt went against them.
But despite all that, and despite playing for an hour with 10 men after Lewandowski's red card, they still managed to leave Pamplona with a victory that ensures they will sit top of LaLiga during the World Cup break after Real Madrid lost to Rayo Vallecano on Monday.
The equaliser had arrived from Pedri, who at 19 already looks ready to take over the midfield from Busquets, who was painfully off the pace here. His poor play led to the corner that Osasuna scored from -- he then lost the goal scorer, David Garcia -- and he gave the ball again moments later for Chimy Avila to hit the side netting.
Barca were able to regroup at the break to secure what could be a very important three points come the end of the season.
2. Lewandowski and Pique see red
There was no 617th Barcelona appearance for Gerard Pique. This was set to be his final game before retirement, but he did not make it onto the pitch after being sent off at the break for remonstrating with referee Jesus Gil Manzano. It was the 11th dismissal of his Barca career.
Pique, who was on the bench as a potential substitute, had been angered by Manzano's first-half performance, and Barca were furious that Garcia's early goal had not been disallowed for an Unai Garcia foul on Marcos Alonso.
According to the referee, Pique's complaints after the halftime whistle continued into the tunnel, where the defender was shown red.
Barca were also disappointed that Lewandowski was sent off earlier in the first half, although they should have fewer complaints about his two yellow cards, especially the second, which was for a high challenge led with his elbow. It was only the second dismissal of his career and his first since 2013.
Luckily for Barca, it did not cost them, while Poland may be pleased he got an extra hour off ahead of the World Cup.
3. Osasuna play well but miss chance to go third
It will be scant consolation tonight but the fact this defeat felt so disappointing is a sign of how good Osasuna have been this season. When they took the lead, they temporarily moved to third in LaLiga. Instead, they ended the night sixth, but there can be no doubt they should be in the running for the European places in the New Year.
Pamplona has always been a difficult place for teams to go and that remains true under coach Jagoba Arrasate. They were the first team to take points of Madrid this season, too, and they will feel they should have done the same against Barca with the numerical advantage.
However, they could not make that advantage pay. They had chances, registering 15 shots to Barca's nine, and until the end it looked like they might nick a draw, but Ante Budimir's later header dropped wide and ended those hopes.
Osasuna: Fernandez 5, Vidal 6, U.Garcia 5, D.Garcia 7, Cruz 6; R.Garcia 7, Moncayola 6, Torro 5, Gomez 6; Oroz 6, Avila 6
Subs: Brasanac 6, Barja 6, Pena 6, Budimir 6, K.Garcia 6
Barcelona: Ter Stegen 6; Balde 7, Christensen 6, Alonso 6, Alba 6; Busquets 3, De Jong 8, Pedri 8; Dembele 6, Lewandowski 3, Ferran Torres 6
Subs: Gavi 6, Raphinha 7, Ansu 6, Chadi Riad 6
Best and worst performers
BEST: Frenkie de Jong, Barcelona
He managed the game well when Barca were reduced to 10 men and filled in brilliantly as a defender late on, producing a brilliant assist for Raphinha's winner.
WORST: Sergio Busquets, Barcelona
Maybe Lewandowski earned a nomination for his petulance, but Busquets was twice at fault for the first goal and struggled most of the night when pressed.
Highlights and notable moments
Osasuna stunned Barca with a goal inside the first six minutes.
García beat Busquets to the ball on a corner kick and nodded it past goalkeeper Marc-André ter Stegen.
OSASUNA LEAD BARÇA 1-0 😱 pic.twitter.com/d6D41hlFmW— ESPN FC (@ESPNFC) November 8, 2022
The proceedings went from bad to worse for Barcelona, however, when Lewandowski earned a second yellow card and was ejected from the match in the 31st minute.
Neither Lewandowski nor anyone on Barca's side have much of an argument though -- he clearly squared up his opponent with no regard for the whereabouts of the ball and took his man out.
Robert Lewandowski sent off for Barcelona for second bookable offence.
The thing about Barca is you can never count them out, and quickly after the break they found their equaliser.
The goal was the third for 19-year-old Pedri this season.
Pedri equalizes for Barcelona
From there, Barca did what they usually do, and they found a way to win with Raphinha's late game-winner.
WHAT A GOAL BY RAPHINHA TO GIVE 10-MAN BARCA THE LEAD!— ESPN FC (@ESPNFC) November 8, 2022
The pass from De Jong 😮 pic.twitter.com/idp0ZZjsBK
After the match: What the players and managers said
Barcelona manager Xavi Hernandez on the result: "I am really proud of the team, of the family that we are inside the dressing room. Everything was against us today: the refereeing decisions, the goal, going down to 10... We were intelligent. We took our moments well and were clinical with the chances we had. We were solid in the second half, worked hard and we will be leaders during the World Cup break. It's a team win today. I am very proud."
Xavi on Pique's red card: "Pique would have come on today because [Andreas] Christensen wasn't able to play 90 minutes and Eric Garcia has some pain. He was the first centre-back to come off the bench."
Osasuna manager Jagoba Arrasate: "It's a shame because we stepped up, even knowing it's not easy against 10. You want to go, but you worry about them catching you on the counter. One mistake in defence can change the game. But it was a good chance for us to take some points."
Key stats (via ESPN Stats & Info)
Lewandowski's red card was his second of his career. His first came in the Bundesliga on Feb. 9, 2023. He has never received a red card with Poland.
Pique's red card was the 11th career of his career with Barcelona, tying Hristo Stoichkov for the most in club history.
Pedri now has three goals in LaLiga this season. That is equal to his goal haul for all of the 2021-22 season.
Raphinha's goal ended a 13-game scoring drought with Barcelona.
Barcelona: Barca break for the World Cup and don't return to action until New Year's Eve when they will host Espanyol in LaLiga on Dec. 31. The kickoff time for that game is not yet set.
Osasuna: Los Rojillos will play once more before the World Cup: Saturday, Nov. 12 at Fuentes in the Spanish Copa del Rey at 10 a.m. ET. (Watch live on ESPN+.)