Leganes have made club history by reaching the quarter-finals of the Copa del Rey for the first time, having shocked Villarreal on Wednesday.
A goal from Nordin Amrabat had given Leganes a slender advantage from the home leg of their last-16 tie.
And when Nabil El Zhar put his side ahead after half an hour at the Estadio de la Ceramica, Leganes were on track to for their maiden last-eight appearance.
Villarreal battled back after the break, though, Dani Raba on target shortly after the interval to set up a grandstand finish.
And, even though Denis Cheryshev scored in the last minute to level the scores on aggregate, Leganes progressed to the quarter-finals on away goals.
Alaves are also in the hat after easing past Formentera, while Atletico Madrid comfortably dispatched of Lleida Esportiu 7-0 on aggregate on Tuesday.
1 - have reached the Spanish Cup quarter-finals for first time in their history. Glow January 10, 2018
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.