Uruguay defender Ronald Araujo has scored deep in added time to snatch a 1-0 win for Barcelona at Real Sociedad, but Girona still lead the Spanish league after beating Osasuna 4-2.
Araujo charged forward to join the attack in the dying moments in San Sebastian and guided home a lobbed pass by Ilkay Guendogan with a header to clinch victory for the visitors.
The goal saw Barcelona move back ahead of Atletico Madrid and into third place. Barcelona trail Girona by four points and second-placed Real Madrid by one.
"Real (Sociedad) is a great team and pressured us all game," Araujo said.
"We didn't play well, above all in the first half. But there are some games you just have to win any way you can."
Sociedad, who are in sixth place, generated several scoring chances — especially in the opening minutes of the game — but were unable to convert.
In Pamplona, Ukraine striker Artem Dovbyk scored one goal and set up two more to lead Girona to victory.
Girona continued to surpass expectations with their convincing win after roaring ahead in a game in which they trailed 2-1 in the second half.
Dovbyk then took charge, heading in to make it 2-2 in the 71st after finishing off a long buildup. It was his sixth goal since joining Girona this season.
He set up fellow countryman Viktor Tsygankov to help put Girona ahead in the 80th. Aleix Garcia volleyed in the fourth goal from just inside the area in the 90th to quash any hope of a late equaliser by Osasuna.
Michel Sanchez's side have 10 wins in 12 rounds. Girona's only loss was against Madrid, who are three points behind before hosting Rayo Vallecano on Sunday.
"We are proud of this win. It sums up what this team represents," Girona defender Eric Garcia said.
"When they went up 2-1, we could have dropped our heads. We deserved this win. Our second half was superb."
Elsewhere, Real Betis moved up to fifth with a 2-0 win over Mallorca and Sevilla escaped with a 1-1 draw at 10-man Celta Vigo after the referee overturned the awarding of an added-time penalty following a video review.