Ansu opened the scoring just before half-time with a well-taken effort from the edge of the box, which was Barca's first shot on target of the match. Antoine Griezmann saw a goal chalked off after the break by VAR for offside against Nelson Semedo before Messi sealed the three points from the penalty spot with his 699th career goal for club and country.
A glittering Barcelona performance this wasn't, but it did, importantly, yield another three points, taking them temporarily five points clear of Real Madrid at the top of the table. They will now hope Valencia can do them a favour at the Alfredo Di Stefano stadium on Thursday.
Ansu's performance -- and goal -- was another highlight. The 17-year-old continues to show that he is more than capable of holding his own at the top level.
In contrast to the win at Mallorca, Barca made a really sloppy start here. They could have been 2-0 behind inside 15 minutes against a Leganes XI that had scored just one league goal between them this season. Fortunately, thanks to a Clement Lenglet goal-line clearance and the post, they survived.
Despite the clean sheet, there were also concerns at the back. The reliable Gerard Pique took a whack to the shin. He was able to play on for a while but did come off eventually. Later, his replacement Samuel Umtiti got booked, meaning he will be suspended for the next match at Sevilla on Friday.
Manager rating out of 10
6 -- Barca's performance won't draw any praise, but the blame shouldn't be attributed to Quique Setien for that. It was just one of those nights. His decision to make five changes was the correct one, given the load of fixtures in the next month, and his substitutions in the second half helped the Blaugrana close the game out.
Player ratings (1-10; 10 = best. Players introduced after 70 minutes get no rating)
GK Marc-Andre ter Stegen, 6 -- A comfortable evening for him after a couple of early scares. As important with his feet as he is with his hands.
DF Sergi Roberto, 5 -- Given the space Messi creates for him on the right, he needs to be much more effective with his end product.
DF Gerard Pique, 7 -- As Leganes frustrated Barca in the first half, he took it upon himself to step forward to try to drive his teammates forward.
DF Clement Lenglet, 7 -- This was his first appearance in three months after missing the Mallorca game through suspension, and he took the chance to blow the cobwebs away. His performance will be best remembered for a brilliant clearance off the line early on.
MF Sergio Busquets, 6 -- Never really got out of second gear before being taken off in the second half for a breather. Perhaps had one eye on Sevilla.
MF Ivan Rakitic, 6 -- A battling performance from the Croatian, who continues to fight for his Barca career on the pitch despite the constant speculation around his future.
MF Arthur Melo, 6 -- Didn't do anything wrong but felt like a missed opportunity to make his case for a regular starting spot. His replacement, Riqui Puig, did much more when he came on late on.
FW Lionel Messi, 8 -- Once again Barca's best player. Won the penalty with an incredible run, winning the ball on the halfway line, nutmegging someone and then somehow holding off two Leganes defenders before a neat one-two with Luis Suarez. The only concern is that's already 180 minutes since the league resumed.
FW Antoine Griezmann, 5 -- Worked hard once again but showing very little in attack. That said, did get on the score sheet in the second half, only to see the goal ruled out for an offside in the build-up.
FW Ansu Fati, 7 -- A rare bright spark in a dour first half. Took his goal really well, taking his tally on the season to six. Could have a big role to play in the run-in.
FW Luis Suarez, 5 -- A second 30-minute cameo in the space of four days should see him in the running for a start on Friday.
DF Nelson Semedo, 6 -- Did better in an attacking sense in half an hour than Roberto in the hour before him.
MF Arturo Vidal, 5 -- Given a run around for the final 25 minutes. Likely to start in Seville.
MF Riqui Puig, NR -- Impressed in his 17 minutes on the pitch.
FW Samuel Umtiti, NR -- In his 17-minute cameo, picked up a booking that will see him miss Friday's encounter with Sevilla.