Madrid's 3-0 victory in the first leg gave Solari's men a strong cushion but they rode their luck at Butarque on Wednesday, having been knocked out of the competition by Leganes last year.
Martin Braithwaite opened the scoring in the first half but, although Leganes looked the likelier team to score the second goal, Madrid avoided conceding again to ensure their place in the last eight.
Solari gave Isco a rare place in his starting XI but the Spain midfielder struggled to make a positive impression in a difficult encounter for a flat Los Blancos.
As they did in the first leg, Leganes started impressively and Sabin Merino narrowly missed the target with a downward header that had Keylor Navas scrambling.
Isco saw a shot blocked at the end of a rapid Madrid break, but Leganes gave themselves hope in the tie with the opening goal on the half-hour mark.
Braithwaite's initial header hit the post but after a goalmouth scramble the striker, who joined on loan from Middlesbrough this month, nudged home his first goal for the club.
Vinicius Junior went close either side of the break but Madrid were toiling, Solari having seen enough and deciding to substitute Isco midway through the second half.
Braithwaite wasted a headed chance to set up a grandstand finish, while Merino should have scored with five minutes remaining.
But a sloppy Madrid somehow held on with substitute Brahim Diaz denied a debut goal for the club in the last minute, his shot rebounding off the post, while Navas made fine saves at the other end from Merino and Braithwaite in added time.
What does it mean? Madrid still unconvincing
Madrid have now lost two of their last four matches since the turn of the year, with Solari still under pressure. A long injury list - featuring Toni Kroos, Gareth Bale and Marco Asensio among other key names - makes for a challenging situation, but his side were totally uninspiring.
Braithwaite an asset for Leganes
On-loan Middlesbrough man Braithwaite performed well in the first leg and he was again a thorn in Madrid's side. He took his goal nicely and gave Madrid defenders Nacho Fernandez and Raphael Varane a serious test, although he probably should have scored more than once.
Ignored Isco fails to justify place
Karim Benzema's fractured finger meant Solari could not ignore Isco any longer, but the playmaker had little impact on a low-key tie that was effectively over after the first leg. Although Isco was typically precise in possession, completing 93 per cent of his passes, there were no magical moments and he wasted Madrid's best chance to score. Isco was predictably hauled off by Solari in the 68th minute, replaced by young striker Cristo Gonzalez.