Frenkie de Jong netted an 87th-minute winner as Barcelona finally found themselves on the right side of late drama in a 1-0 victory at Deportivo Alaves.
Barca entered the game on a three-match winless run in all competitions, having been held by Granada following a last-gasp equaliser before consecutive cup defeats after extra-time.
The stage was set for another frenzied finish after Luuk de Jong passed up two presentable opportunities for the Blaugrana, and it was his namesake who delivered this time.
Xavi's men leapfrogged Real Sociedad into fifth place in the LaLiga table, a point behind Atletico Madrid after their own late show a day earlier.
On a long night, Barca were on top from the outset but struggled to break down Alaves before Frenkie de Jong's intervention.
Luuk de Jong volleyed the best of their first-half openings wide, although Pere Pons should have done more than shoot tamely straight at Marc-Andre ter Stegen on the counter just before the break.
Forward Luuk de Jong had the clearest opportunity after the restart, too, but could not make a clean contact with Pedri's driven cross, allowing Fernando Pacheco to block at close quarters.
Joselu thundered a header wide when Alaves might have snatched all three points, before the winner instead arrived at the other end.
Ferran Torres stayed onside to reach Jordi Alba's deep pass and tee up Frenkie de Jong for a simple finish and a lead that was not squandered in the closing stages on this occasion, despite a 93rd-minute headed chance for Edgar Mendez.