Barcelona's Ronald Araujo headed a stoppage-time goal to snatch a 1-0 win at Real Sociedad on Saturday as they kept pace with the leaders in La Liga after being outplayed by the hosts.
Real Sociedad had chances in the first half but were foiled by Marc-Andre ter Stegen.
Barca's best opportunity came from Fermin Lopez before the break.
Sociedad keeper Alex Remiro then made a brilliant save to deny Gavi and Ronald Araujo had an effort disallowed for offside before he popped up with the winner in the 92nd minute.
The victory puts Barcelona in third place on 27 points from 12 games, four points off leaders Girona who won 4-2 at Osasuna earlier on Saturday.
Ukraine striker Artem Dovbyk scored one goal and set up two more to lead Girona to victory in Pamplona. 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. Michel Sanchez's side has 10 wins in 12 rounds. Girona's only loss was against Madrid.