Ousmane Dembele scored early in extra time after missing a penalty late in regulation as Barcelona defeated third-division Cornella 2-0 in the round of 32 of the Copa del Rey on Thursday.
Martin Braithwaite also scored for Barcelona, who had already seen Miralem Pjanic miss a penalty in the first half.
In the Spanish league, Luis Suarez scored twice as leaders Atletico Madrid came from behind to defeat Eibar 2-1 and open a seven-point gap to second-place Real Madrid.
Barcelona avoided an upset in the Copa del Rey a day after Real Madrid lost 2-1 to third-division club Alcoyano in extra time. Atletico had already been stunned by Cornella in the second round.
Barcelona advanced despite playing without Lionel Messi, who is suspended for two matches after striking an opponent away from the ball in the team's 3-2 loss to Athletic Bilbao in the Spanish Super Cup final on Sunday.
Dembele scored with a right-foot shot from outside the area two minutes into extra time. He had his 80th-minute penalty saved by Cornella goalkeeper Ramon Juan Ramirez, who also stopped Pjanic's spot kick just before half-time.
Barcelona controlled possession but struggled to capitalise on their many scoring chances on the artificial turf at the small Cornella stadium in Catalonia. The hosts threatened a few times on counterattacks.
Cornella went a man down when Albert Estelles was sent off with a second yellow card in the final minutes.
Braithwaite's goal came on a breakaway just before the final whistle.
Meanwhile Suarez scored a goal in each half after Eibar took the lead with a penalty converted by goalkeeper Marko Dmitrovic in the 12th minute.
Suarez equalised in the 40th with a low cross shot from close range after the Eibar defence failed to clear the ball from inside their area.
The Uruguay striker netted the winner by converting an 89th-minute penalty after he was fouled inside the area.
It was the sixth league win in a row for Atletico, who still have a game in hand compared to Real Madrid and third-place Barcelona, who are 10 points off the lead.
"We have to understand that it's very difficult to win these matches," Suarez said. "We need to keep playing at a high level if we want to achieve our goals."
Eibar, winless in three matches in all competitions, are in 15th place, two points from safety.
In a match between clubs fighting against relegation, Valencia were held to a 1-1 draw against Osasuna.
Jonathan Calleri put the visitors ahead with a volley in the 42nd and Valencia equalised with an own goal by Osasuna defender Unai Garcia in the 69th.
Winless in 13 consecutive league games, Osasuna stayed second-to-last in the 20-team standings. Valencia are 14th, three points from the relegation zone.
Australian Associated Press