With 10 minutes left to play, Toko Ekambi doubled the lead after an assist from Santi Cazorla.
El Zhar was introduced for Oscar in the 71st minute and scored the consolation goal for his side from the penalty spot.
Toko Ekambi made way for Gerard Moreno in the 89th minute while Nigeria's sensational Samuel Chukwueze was replaced with six minutes left to play.
Super Eagles defender Kenneth Omeruo, who ended up with the losing side, featured for the entire duration of the match and was cautioned in the game.
The result saw Villarreal climb to 14th spot while Leganes dropped to 12th place on the table.
Toko Ekambi has 17 goals in all competitions this season and he will hope to replicate his impressive club performances for Cameroon in the 2019 Africa Cup of Nations in Egypt, slated for June and July.
The Indomitable Lions are in Group F alongside Benin, Ghana and Guinea-Bissau.