Real Sociedad came into the match on the back of nine consecutive wins in all competitions and almost scored in the 29th minute when Japanese youngster Take Kubo's strike hit the bar.
Barcelona were the better side for most of the match after that but only scored once thanks to a brilliant counter-attack by man-of-the-match Dembele in the 52nd minute.
Sociedad should have equalised seven minutes later but Alexander Sorloth missed a sitter, skying a shot from inside the six-yard box from a Kubo cross.
After Gavi volleyed against the crossbar from a great cross by Dembele in the 68th minute, Real made a late push and could have scored on at least three occasions, with Barca keeper Marc-Andre ter Stegen making a string of saves to secure the win.
"It was a struggle for us after they were one-man down because they closed down well and defended relentlessly," Barca defender Ronald Araujo told Movistar Plus.
"I'm sure [coach] Xavi will give us a slap on the wrist, we probably should have closed out the game earlier. Now we need to correct the mistakes and move forward. I'm happy because we won at home and we continue on a good run."
Osasuna joined Barcelona in the semifinals after they beat Sevilla 2-1 later on Wednesday thanks to an extra-time goal by Abde Ezzalzouli.
Chimy Avila opened the scoring for the hosts in the 71st minute but Youssef En Nesyri equalised in the 94th minute, taking the match to extra time.
Substitute Ezzalzouli scored the winner nine minutes into extra time on a counter-attack, slotting a right-foot shot inside the right post.
In the other quarterfinals, Real Madrid face Atletico Madrid and Valencia meet Athletic Bilbao on Thursday.