Published: 2020-01-31 02:57:02 BdST
Leganes, second-bottom of La Liga, made a number of changes from the side that secured a 0-0 draw against Atletico Madrid at the weekend and a full-strength Barca took advantage.
Last season's Copa runners-up went ahead after four minutes when Nelson Semedo raced onto Messi's through ball and squared for Antoine Griezmann to finish from close range.
Griezmann was denied a second after a lengthy VAR stoppage deemed the French forward offside in the build-up.
Messi turned provider when Clement Lenglet nodded in from a corner to double the Catalan side's advantage.
The Argentine added a deflected third on the hour before rounding off the scoring in the final minute after substitute Arthur had netted the fourth.
Barca joined Real Madrid, Villarreal, Athletic Bilbao, Granada, Real Sociedad and holders Valencia in the pot for Friday's draw.
Sevilla visit second tier Mirandes later on Thursday in the final round of 16 game.