Messi had started on the bench, rested by coach Ernesto Valverde, and for just over an hour at the Camp Nou, Dembele filled the void by scoring the opening goal in a sparkling individual display.
The 21-year-old, however, limped off with a sprained ankle in the 69th minute, shortly after Leganes had equalised through Martin Braithwaite and Valverde responded by introducing Messi.
He needed only seven minutes to make an impact as his bending shot was followed up by Luis Suarez, who poked the ball in ahead of Leganes goalkeeper Pichu Cuellar. Messi then rounded off the win by scoring himself in injury-time.
Leganes had protested against Suarez’s finish, convinced that Pichu had been fouled by a high foot.
“It was a clear foul,” coach Mauricio Pellegrino said. “Barca don’t need these kind of decisions to help them.”
But VAR disagreed and Barca advanced to what was, in truth, a fully deserved victory. It means they regain their hefty advantage over Atletico Madrid at the top of the table, with the difference ahead of Real Madrid also back to 10 points.
Leganes had beaten Barcelona at home in September but that remains the high point of their season. They stay 14th.
Valverde was accused of failing to rest key players last term, to the detriment of their progress in the Champions League, and his gamble to spare his star player just about paid off.
“There are lots of games,” Valverde said. “We talk to the players and decide when it may be good for them to rest.”
“It was difficult with and without Messi,” Pellegrino said.
Barcelona needed him in the end but for a while, Dembele, and the 21-year-old Carles Alena in midfield, had shown there may yet be life after Messi, who turns 32 in June.
Dembele will undergo tests on Monday. “We will miss him a lot,” Valverde said. “We hope it is not too long.”
He was at the heart of everything in the first half, his hips slaloming through the hapless Leganes defence, who swarmed around him in numbers but always seemed a step behind.
A cheeky nutmeg was followed by an audacious scoop, which found Suarez but he poked wide. It was a classy finish for the opener too, although the goal owed more to the collective than individual.
Gerard Pique started it, driving from deep in defence down the wing. Alena took over and found Dembele, who spread the ball wide to Jordi Alba. When the ball came back, Dembele opened up his body and his right foot, guiding the ball first-time into the bottom corner.
After half-time, Philippe Coutinho fired over after another Dembele flick and it felt like only a matter of time before another goal would come.
It did, but Leganes scored it, with their second shot on target. Alba was caught out and Youssef En-Neysri nipped in. His fizzing cross found Braithwaite, who darted ahead of Pique to prod home.
Messi had been warming up and was quickly introduced. Alena made way and shortly after Dembele followed, his brilliant night cut short. Malcom came on.
Seven minutes passed between Messi’s substitution and Suarez’s goal. Messi cut in from the right and curled a shot towards the top corner, where Pichu dived to meet it and palmed the ball into the air.
As it dropped, Suarez got there first, stabbing in the rebound at around hip-height before clattering into the keeper’s chest. VAR checked and Leganes protested. The goal stood.
Suarez should have scored again but shot straight at Pichu, who gathered, rushed out and barged into the shoulder of the Uruguayan.
Any doubt was dispelled, however, as Messi exchanged with Alba in injury-time. A swoop of the Argentinian’s right foot was all it needed.Source: