Barcelona missed two penalties in normal time, with midfielder Miralem Pjanic being thwarted late in the first half by Cornella keeper Ramon Juan before Dembele hit straight at the feet of the 21-year-old in the 80th minute from yet another spot kick.
Dembele made amends with a vicious long-range strike in the second minute of extra-time which Ramon Juan got a hand to but was powerless to prevent it rocketing into the net.
Danish forward Braithwaite, who had missed a clear chance to win the game late in normal time, then sealed a nervy Barca victory moments after Cornella's Albert Estelles had been sent off.
Barca are the only surviving team of Spain's top three clubs in Friday's last-16 draw after Real Madrid were knocked out by Alcoyano on Wednesday, while La Liga leaders Atletico Madrid were beaten by Cornella last week.
Barca coach Ronald Koeman was relieved to reach the next round but was frustrated with his side's inability to kill the game off long before, meaning they played 120 minutes for the third match in a row after playing extra-time in the Spanish Super Cup against Real Sociedad and Athletic Bilbao last week.
"The most important thing is that we got through to the next round but we cannot be happy because we missed a lot of clear chances, we missed two penalties and we need to show more responsibility in games like this," he told reporters.
"We played 120 minutes once again, that's a big thing for us. And after creating so many chances and missing two penalties. This cannot be."
Cornella coach Guillermo Fernandez Romo said his side had done themselves proud but was still sad they could not finish the job.
"I don't feel good about the result but everything else I saw tonight makes me proud. We played with dignity and I'm so impressed with my players, because my impression is that it was an even game until the 80th minute," he said.