Barcelona missed two penalties before edging into the Copa del Rey last 16 with two extra-time goals against third-tier Cornella.
Miralem Pjanic and Ousmane Dembele were both denied from the spot by Cornella goalkeeper Ramon Juan in normal time.
Juan, 21, is the first keeper ever to save two Barca penalties in one game.
Dembele made amends with a long-range strike two minutes into extra time, while Martin Braithwaite added a second after Albert Estelles was sent off.
Barcelona had reason to be apprehensive going into the tie, as Cornella - who play in Segunda Division B - had knocked out current La Liga leaders Atletico Madrid in the previous round.
In addition, Barca's tie was played the evening after their great rivals Real Madrid had suffered Copa del Rey humiliation, having been beaten in extra time by third-tier side Alcoyano - who scored their winning goal after being reduced to 10 men.
But Ronald Koeman's men - taken to extra time in their previous two games, both in the Spanish Super Cup - came through another 120-minute test to avoid a similar upset.
They now turn their attention back to La Liga duties with an away game with Elche on Saturday.
Koeman will still be without Lionel Messi, however, as the Barcelona captain serves the second of his two-game ban for his red card against Athletic Bilbao in the Super Cup final, which his team lost.
Line-ups
Cornellá
Formation 4-4-2
- 1Juan
- 11Guzmán
- 2EstellésBooked at 118mins
- 18Moreno
- 24Martín Langreo
- 7GilaSubstituted forPla Pegueroat 97'minutes
- 6PresaBooked at 57minsSubstituted forSanmartíat 84'minutes
- 4Dorca
- 8MarcetSubstituted forBorregoat 68'minutes
- 20Medina DelgadoBooked at 96mins
- 21OntiverosSubstituted forCarmonaat 68'minutes
Substitutes
- 9Borrego
- 13Santaella Cáceres
- 14Pla Peguero
- 19García
- 25Mourin
- 26Sanmartí
- 27Caroutas
- 28Vilaplana
- 29Carmona
Barcelona
Formation 4-3-3
- 13Neto
- 28Mingueza
- 4Araujo
- 15Lenglet
- 24Firpo
- 27Kourouma KouroumaSubstituted forBusquetsat 74'minutes
- 8PjanicBooked at 106mins
- 12PuigBooked at 7minsSubstituted forDembéléat 45'minutes
- 17Machado TrincãoSubstituted forPedriat 74'minutes
- 9Braithwaite
- 7GriezmannSubstituted forDe la Fuenteat 101'minutes
Substitutes
- 1ter Stegen
- 5Busquets
- 11Dembélé
- 16Pedri
- 19Fernandes Siqueira
- 23Umtiti
- 29De la Fuente
- 30Collado
- 36Tenas
- Referee:
- César Soto Grado
Match Stats
- Possession
- Home27%
- Away73%
- Shots
- Home12
- Away23
- Shots on Target
- Home4
- Away9
- Corners
- Home7
- Away13
- Fouls
- Home20
- Away17