Ronald Koeman's men had two penalties saved in normal time as they failed to break down the Segunda B side who famously knocked out Atletico Madrid in the previous round.
Miralem Pjanic and Dembele each missed from the spot but the latter eventually made the breakthrough with a powerful strike.
The visitors made sure of the win in the very last moment through Braithwaite to ensure there would be no repeat of Wednesday's action, when Real Madrid suffered one of the biggest shocks in the competition's history by losing to Alcoyano.
Barca struggled to turn possession into chances, their first real effort of note coming via a Francisco Trincao volley from Pjanic's corner that was parried by Ramon Juan.
Pjanic had the chance to break the deadlock from the spot after Ronald Araujo took a high foot to the head, but his penalty was expertly saved.
They started the second half with more purpose and should have scored when Martin Braithwaite shot straight at Ramon after Antoine Griezmann diverted the ball into his path.
Griezmann then blasted over the bar with the goal at his mercy after a clever quick free-kick from Pjanic, and Neto had to make a flying save to parry an Agus Medina strike barely a minute later.
Substitute Dembele was given the chance to get the breakthrough 11 minutes from time after another high boot in the box, this time from Pol Moreno on Clement Lenglet, but Ramon held his nerve and blocked the penalty from the middle of his goal.
Braithwaite sliced another clear chance wide of the right-hand post and Ramon came to the rescue again to tip a Pjanic half-volley onto the crossbar and away.
Yet within two minutes of the beginning of extra time, Ramon's resistance was broken, the keeper getting two hands to Dembele's strike from 20 yards out but unable to keep the ball out of the net.
Konrad de la Fuente almost made it 2-0 immediately after coming off the bench, but Ramon threw himself to his left to make another fine stop, before Albert Estelles earned a second booking in the closing moments for a poor challenge on the excellent Araujo.
With the final move of the game, Dembele combined expertly with Pedri, who unselfishly teed up Braithwaite to drill into the unguarded net.