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.
The 21-year-old 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 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.
Â
Â
Â