Ousmane Dembele scored an injury-time winner as Barcelona left it late to sink 10-man Real Valladolid 1-0 at the Nou Camp.
Dembele volleyed home at the far post to seal his side's sixth straight La Liga win and move within one point of leaders Atletico Madrid.
It was harsh on the struggling visitors, who looked set to hold out for a point despite the 79th-minute dismissal of Oscar Plano.
Valladolid went into the game on the back of just one win in their past 11 and without a number of regulars due to injury and a coronavirus outbreak.
But they had the better of the first half-hour with Kenan Kodro crashing a header back off the bar and Roque Mesa also coming close from long-range.
Dembele and Pedri had chances for below-par Barca before half-time, but Lionel Messi's men continued to struggle after the break.
Lucas Olaza had another fine chance for the visitors just before the hour mark when he raced down the left before cutting in and striking an effort into the side-netting.
A strong penalty shout for handball against Jordi Alba was denied as the home side rode their luck and stepped up their search for a winner.
It duly arrived as the game ticked over into injury time as Ronald Araujo flicked on a cross from Frenkie De Jong and Dembele pounced to snatch the points.