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.
- 2EstellésBooked at 118mins
- 24Martín Langreo
- 7GilaSubstituted forPla Pegueroat 97'minutes
- 6PresaBooked at 57minsSubstituted forSanmartíat 84'minutes
- 8MarcetSubstituted forBorregoat 68'minutes
- 20Medina DelgadoBooked at 96mins
- 21OntiverosSubstituted forCarmonaat 68'minutes
- 13Santaella Cáceres
- 14Pla Peguero
- 13Murara Neto
- 27Kourouma KouroumaSubstituted forBusquetsat 74'minutes
- 8PjanicBooked at 106mins
- 12PuigBooked at 7minsSubstituted forDembéléat 45'minutes
- 17Machado TrincãoSubstituted forGonzálezat 74'minutes
- 7GriezmannSubstituted forDe la Fuenteat 101'minutes
- 1ter Stegen
- 19Fernandes Siqueira
- 29De la Fuente
- César Soto Grado
- Shots on Target