Messi created one goal and scored another to keep the Catalans five points clear at the top, after the visiting side had drawn level and started threatening an upset.
The Argentine, left out of the starting line-up for only the second time this season when fit, was called on with 64 minutes on the clock and the game poised at 1-1.
This was after Leganes forward Martin Braithwaite had cancelled out Ousmane Dembele’s first half opener with a 57th minute strike.
Messi quickly provided the spark Barca needed by firing a venomous shot from outside the area, which was too powerful for goalkeeper Ivan Cuellar to hold.
Luis Suarez pounced to stab home the rebound in the 71st minute, after a lengthy video assistant referee (VAR) review.
The La Liga top scorer made sure of the victory in stoppage time, sweeping across the area and hammering the ball past a helpless Cuellar.
It was his 18th goal of the season in Spain’s top flight.
The win took leaders Barca to 46 points, five clear of nearest challengers Atletico Madrid, after 20 games.(Reuters/NAN)