Barcelona’s needed a 90th-minute penalty from Lionel Messi to overcome 17th-placed Leganes 2-1 in La Liga on Sunday.
Messi put the hosts up almost right out of the gates, striking from close range in the fourth minute, with Luis Suarez providing the assist.
But, with Barca trying to extend the lead, the visitors found a shock equaliser in the 71st minute, when Darwin Machis found Unai Lopez, who slotted home from the centre of the penalty area past Marc-Andre ter Stegen.
With time running out, Neymar drew a foul in the penalty area to give Messi the chance, and the Argentine came through to spare his team blushes and rescue all three points.
The Liga holders, who moved back into second place ahead of Sevilla with the win, were embarrassed by Paris Saint-Germain on Tuesday, losing 4-0 in the first leg of the teams’ round-of-16 tie.