The Blanquivioletas, until then, had done brilliantly to keep their mighty hosts at bay, even though plenty of chances at the other end went begging.
As the match seemed to be headed for a draw, Dembele popped a late winner from near post, smashing home beyond the indomitable Jordi Masip.
The victory brings Ronald Koeman's side within a point of Rojiblancos, just a week before the all-important El Clasico against holders Real Madrid.
Real Valladolid can be proud of their performance and on this evidence, can easily remain in the top-flight for another season.
Here are the player ratings for Barcelona:
Marc-Andre ter Stegen - 7/10
Real Valladolid showed tremendous attacking flair in the match and ter Stegen had to be on his toes throughout, even though the ball rarely came directly at him. Yet, the custodian held his ground well and earned another clean sheet.
Oscar Mingueza - 6/10
Not the best night for the burgeoning Spaniard, who struggled to cope with Valladolid's pace on the break and didn't attempt a single tackle all night.
Frenkie de Jong - 7/10
He was solid defensively when Valladolid were on the front foot, but his best moments came when he stepped into the midfield, giving their defense some real cause of concern and also put in the cross which culminated in Dembele's late-winner.
Clement Lenglet - 7/10
Lenglet played a big role in keeping Valladolid at bay despite their attacking flair, making six clearances on the night to safeguard his net, most noteably denying Sergi Guardiola with a fantactic headed clearance in the fifth minute.
Sergino Dest - 6/10
He was largely ineffective when surging forward, especially in the first-half, unable to deliver anything of note to his attacking colleagues. Dest was also caught out on the break but found his feet when Barcelona switched to a back-four.
Sergio Busquets - 6/10
As always, the veteran midfielder kept the ball moving, but couldn't quite break down Valladolid. His off-the-ball pressing resulted in three ball recoveries too.
Pedri - 7/10
Pedri was at his industrious self again and heavily involved in Barca's attacking plays. He even stung Masip's hands with a powerful effort in the second-half.
Jordi Alba - 7/10
He fulfilled his defensive duties with elan, even tracking back whenever needed, but also made his presence felt in the attacking areas with lovely deliveries, including one key pass.
Lionel Messi - 7/10
The heartbeat of the side once again tonight, Messi kept the attacking juices flowing with his wonderful throughballs, whilst also attempting a few good shots himself. He laid five key passes in the game, including that sublime one to release Dembele who then fired straight at Masip.
Antoine Griezmann - 7/10
Lot of running and getting between the lines from the Frenchman, though never really a direct threat, besides that one moment when he fired his header just wide off the post from a few yards out.
Ousmane Dembele - 8/10
Dembele huffed and puffed all night, struggling to finish off a couple of good chances, but then slotted home the 90th minute winner at the near post to rescue all three points. His fine season continues with another massive contribution.
Ronald Araujo - 7/10
He inadvertently flicked on De Jong's cross onto the path of Dembele to claim the assist for his winning goal.
Francisco Trincao - 6/10
Trincao made a few good runs down the right flank but was never a direct threat.
Martin Braithwaite - 6/10
The Dane produced a smart flick inside the area to play on Messi and then went into the books for catching Nacho on the loose arm.
Ilaix Moriba - 6/10
The youngster saw a headed effort just wide of target.