The Blaugrana had not been as convincing as the scoreline suggested when they thrashed 4-0 Real Mallorca away at the weekend, and they toiled against another struggling outfit on Tuesday
But Quique Setien's side secured another three points after Fati - Barca's standout star - broke the deadlock three minutes before half-time.
Messi then scored his 699th goal for club and country from the penalty spot as Barca extended their advantage at the top of the table to five points, at least until Real Madrid host Valencia on Thursday.
Leganes coach Javier Aguirre was shown a red card in stoppage time, seemingly for dissent, on a frustrating evening for the bottom side.
Barca, who took just 65 seconds to score against Mallorca on Saturday, had been fortunate not to faLell behind to Leganes early on.
Miguel Angel Guerrero twice beat Marc-Andre ter Stegen from the right-hand side of the penalty area, only to be denied by first Clement Lenglet, retreating to his goal line, and then the outside of the far post.
5 - @FCBarcelona's Ansu Fati has become the second youngest player to score five goals in @LaLigaEN in the 21st century (17 years, 229 days), after Bojan Krkić (17 years, 201 days). Stellar. pic.twitter.com/c62HeNuroD— OptaJose (@OptaJose) June 16, 2020
The Catalan giants were clinical when their moment came late in an otherwise frustrating first half, though, as Fati fired a sweet low finish into the bottom-right corner from just inside the box.
The officials then took centre stage in the second period, with the VAR asked to assess a pair of controversial moments in quick succession.
Antoine Griezmann saw a goal ruled out when replays showed Nelson Semedo was a step offside before crossing for his team-mate to tuck into the net.
But Barca did not need to wait long for their second, as Messi held off a series of robust challenges before going down just inside the area under minimal contact to win a penalty that he dispatched following another video review.
Aguirre saw red in the closing stages as toothless Leganes remained bottom.
What does it mean? Suarez the key
If the sign of champions is a side playing poorly and still winning, LaLiga might as well hand Barca the trophy now. Comfortable results have disguised tough tests against mediocre opposition in recent days, with trickier quests to come.
But as against Mallorca, Barca looked a different team once Luis Suarez was called from the bench to combine with Messi. His pass led to the penalty award and a fully fit front line should prompt improvement.
Fati to the fore
With Suarez still not quite fit to start, Fati was promoted to the starting XI in place of Martin Braithwaite and certainly made his mark. The 17-year-old's fifth league strike punctuated a lively display in which he linked up well with Junior Firpo, the threat coming from the left in a quiet first half for Messi.
More Griez groans
This was another frustrating outing for Griezmann. Still searching for his best form in a Barca shirt, the striker was largely ineffectual in the first half and guided one header well wide. But he looked to have added to his Blaugrana tally in the second period, only to see Semedo flagged offside.
After playing consecutive matches against sides facing relegation battles, a more demanding fixture awaits Barca next up as they go to Sevilla on Friday. Leganes have a huge clash against Mallorca on the same day.