Barcelona's Ousmane Dembele had a penalty saved in the 80th minute
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-upsMatch Stats
1Juan11Guzmán2Estellés18Moreno24Martín Langreo7Gila6Presa4Dorca8Marcet20Medina Delgado21Ontiveros
- 1Juan11Guzmán2EstellésBooked at 118mins18Moreno24Martín Langreo7GilaSubstituted forPla Pegueroat 97'minutes6PresaBooked at 57minsSubstituted forSanmartíat 84'minutes4Dorca8MarcetSubstituted forBorregoat 68'minutes20Medina DelgadoBooked at 96mins21OntiverosSubstituted forCarmonaat 68'minutes
- 9Borrego13Santaella Cáceres14Pla Peguero19García25Mourin26Sanmartí27Caroutas28Vilaplana29Carmona
13Murara Neto28Mingueza4Araujo15Lenglet24Firpo27Kourouma Kourouma8Pjanic12Puig17Machado Trincão9Braithwaite7Griezmann
- 13Murara Neto28Mingueza4Araujo15Lenglet24Firpo27Kourouma KouroumaSubstituted forBusquetsat 74'minutes8PjanicBooked at 106mins12PuigBooked at 7minsSubstituted forDembéléat 45'minutes17Machado TrincãoSubstituted forGonzálezat 74'minutes9Braithwaite7GriezmannSubstituted forDe la Fuenteat 101'minutes
- 1ter Stegen5Busquets11Dembélé16González19Fernandes Siqueira23Umtiti29De la Fuente30Collado36Tenas
Referee:César Soto GradoMatch StatsHome TeamCornelláAway TeamBarcelonaPossessionHome27%Away73%ShotsHome12Away23Shots on TargetHome4Away9CornersHome7Away13FoulsHome20Away17