Antoine Griezmann and Clement Lenglet scored first-half goals before Lionel Messi netted two and Arthur added another after the break as Barcelona reached the last eight of the Copa for the 10th straight year.
Setién fielded a strong lineup after resting Messi and other regular starters in the previous round, when it barely avoided elimination thanks to two late goals by Griezmann against third-division club Ibiza.
Setién was under pressure because of the team’s lackluster performances since he took over from Ernesto Valverde this month. Barcelona was coming off a 2-0 loss at Valencia, a result that cost the team the Spanish league lead.
The Catalan club was in control from the start against Leganés, though, creating a series of chances and rarely being threatened by its relegation-threatened opponent. Leganés sits second-to-last in the Spanish league standings.
Griezmann opened the scoring less than five minutes into the game with a shot from close range after a pass by Nélson Semedo, and defender Clement Lenglet added to the lead with a header from a corner taken by Messi in the 28th. Messi scored from inside the area in the 59th and 89th minutes, while substitute Arthur netted in the 78th.
Griezmann had a goal disallowed for offside shortly after his opener at the less-than-packed Camp Nou Stadium.
Barcelona last failed to reach the Copa quarterfinals in 2009-10, when it was eliminated by Sevilla in the round of 16. The Catalan club was runner-up to Valencia last year.
Valencia and Real Madrid advanced to the last eight on Wednesday. The defending champion eliminated third-division club Cultural Leonesa on penalties and Madrid routed second-division club Zaragoza 4-0.
The Copa del Rey is being playing in single-elimination games this season, except in the semifinals.
The draw for next week’s quarterfinals will be on Friday.