Leganes tried to become the first team to beat Barcelona this season, but Valverde's men battled to yet another victory in what was altogether an unconvincing display.
That was largely due to the hosts, who in the first half dealt comfortably with Barcelona's efforts to break the deadlock. However, the hosts saw their organised back line finally broken down in cruel fashion, with goalkeeper Ivan Cuellar spilling the ball into the path of Luis Suarez to lash in the rebound from Paco Alcacer's shot. The Uruguayan did not waste the gift, ruthlessly punishing Leganes.
After 30 minutes of restless toiling in defence. the hosts were slightly dumbstruck, but they did not sit back as they looked for a quick response. Alexander Szymanowski tested Ter Stegen inside the Barca area but the German keeper pushed it to safety.
Ernesto Valverde's men failed to find fluency to their game and were limited to few chances, while Leganes piled pressure on the Catalans in the final third.
The hosts looked similarly lively after the break, and were very much still in the contest until Luis Suarez put the game out of reach. Claudio Beauvue had just fired a low shot straight at Ter Stegen before the visitors were up the other end causing trouble.
Luis Suarez relieved his side from the pressure with an emphatic volley past Cuellar, who could only parry Alcacer's strike into the path of the striker. Suarez reacted the sharpest and his acrobatic finish was too powerful for the keeper.
Having extended their lead, Barcelona were at a degree of comfort for the first time in the afternoon. Leganes were understandably deflated but, with the away side closing in on a third goal, they never gave up hope of a comeback.
Aleix Vidal blazed his effort wide from close range and Messi, who made little impact on the game, forced Cuellar into action with a curling shot from 20 yards. Luis Suarez attempted to put in the rebound to complete his hat-trick, but the stopper recovered brilliantly.
The La Liga leaders finally capped off their performance with a third goal in the dying moments. Messi again involved as he worked his way inside the box and he flicked the ball back from the byline for Paulinho to poke into the net.
The result was harsh on mid-table Leganes, while further ensuring Barcelona's presence at the summit of La Liga table with a seven-point gap with runners-up Valencia and an 11-point difference with Real Madrid ahead of Saturday's derby in the Spanish capital.