Ousmane Dembele let go in to give the bosses a first-half lead before Martin Braithwaite, on advance from Middlesbrough, tapped in the equalizer.
Luis Suarez gave Barca the preferred standpoint again when he jabbed home after Messi’s sublime free-kick had been spared.
Messi then got the third in stoppage time with a pounding shot.
Remember the activity for Camp Nou
The outcome moves Ernesto Valverde’s group to 46 points from 20 diversions, five in front of second-put Atletico Madrid with main opponents Real Madrid third with 36 points.
Be that as it may, it appeared for some time that Barca’s leverage would be just three going into the following round of recreations.
The apparatus started splendidly for the Catalan club amid an uneven first half commanded by the brightness of France forward Dembele, his duplicity and exciting pace humiliating the restriction protection on occasion.
The main case of his rankling speed came in the twelfth moment when he burst into the territory before sustaining Philippe Coutinho, who discharged his shot high over the bar.
At that point came his objective. Protector Gerard Pique started the move by spilling past two Leganes players, before the ball in the end came to Jordi Alba on the left.
The Spaniard discovered Dembele in the zone, who turned his foot and coordinated a first-time strike past the range of Ivan Cuellar.
Mid-table Leganes scarcely compromised the Barca region, however that changed after the break when Braithwaite changed over from short proximity following a quick break.
Messi and Ivan Rakitic were presented not long after, in spite of the fact that Barcelona endured another pass when Dembele came over with a lower leg damage.
Regardless of that mishap Barcelona reasserted their control. They led the pack yet again when Cuellar neglected to manage Messi’s strike and Suarez jabbed in.
Furthermore, in stoppage time, Messi made sure of the focuses with a furious right-foot complete after great mix play with Alba.