Ousmane Dembele volleyed in a 90th-minute winner against Real Valladolid on Monday to fire Barcelona to within a point of Atletico Madrid ahead of next weekend's Clasico in La Liga.
Barca looked set for a damaging stalemate at Camp Nou after Atletico's defeat by Sevilla on Saturday but Valladolid had Oscar Plano harshly sent off with 12 minutes left and Dembele snatched a 1-0 victory.
His strike could prove a crucial moment in the Spanish title race, with Barca now breathing down Atletico's necks ahead of Saturday's meeting with Real Madrid, who are three points off the top.
If Ronald Koeman's men win at Valdebebas, they will claim first place for 24 hours at least, before a depleted and deflated Atletico play away at Real Betis on Sunday.
They will have to play better after being frustrated by a determined Valladolid side, with Lionel Messi delivering some firm words to his team-mates in the tunnel at half-time.
"We have to step it up a gear, we have to play with more rhythm," Messi said. "If not it's going to get complicated for us."
It might have been more complicated had Plano not been shown a red card in the 78th minute, his hack on Dembele from behind giving Barca a crucial advantage for the final stages.
Victory makes it six in a row for them in La Liga, another win - particularly after an unconvincing performance - enhancing the sense that momentum now lies with Atletico's rivals.
Defeat also compounded what Valladolid coach Sergio admitted on Sunday had already been a "sh**ty week" after five of his players tested positive for Covid-19, leaving him without 12 players, with six others injured and one more suspended.
To mark Messi breaking Xavi Hernandez's appearance record for the club, he was presented with a framed shirt before kick-off, which he accepted with his family on the pitch. Messi passed Xavi's previous record of 767 appearances last month, with this his 769th.
Valladolid were not just able to compete in the first half, they were probably the better side and could have led when Kenan Kodro's early header struck the bar.
Dembele broke through and dragged back for Messi, whose shot was blocked, while Pedri's long-range effort fizzed through and came back off the post.
But Barcelona were flat, their passing predictable and there was concern in Messi's voice when he told his team-mates to find a different gear in the second half.
Valladolid were almost undone by a Messi through ball for Dembele, who held his run but could not finish before the leaping Antoine Griezmann headed the rebound wide.
Barcelona looked more dangerous on the break than in possession and they were lucky to escape a penalty when Oscar Plano poked the ball onto the outstetched hand of Jordi Alba.
Koeman made three changes shortly after, Martin Braithwaite, Francisco Trincao and Ronald Araujo replacing Griezmann, Sergio Busquets and Oscar Mingueza.
But Barca's biggest boost came 12 minutes from the end, when Plano was sent off for chasing Dembele back and tripping the Frenchman from behind. A yellow card seemed the more obvious decision.
Trincao went close and the winner came in the last minute as Frenkie de Jong's cross was flicked to the back post by Ronald Aruajo. Dembele was free and lashed into the corner.
(For more sports news and updates, follow Ahram Online Sports on Twitter at @AO_Sports and on Facebook at AhramOnlineSports.)