Stuttering Villarreal closed to within a point of the Champions League qualification places when a second-half Cedric Bakambu double secured a 2-1 comeback win at home to Rayo Vallecano in La Liga on Sunday.
Jozabed Sanchez put Rayo ahead four minutes before halftime at the Madrigal stadium before Bakambu struck in the 69th and 86th minutes to give Villarreal only a second victory in their last eight outings in Spain's top flight.
With 14 matches played, Villarreal are fifth on 24 points, one behind fourth-placed Celta Vigo after the Galician club drew 1-1 at Real Betis on Saturday.
"We had to win at all costs," Villarreal midfielder Denis Suarez told Spanish television.
"They are a vital three points as we have been on a very bad run and we are very pleased," he added.
"We maintained our intensity, we attacked and kept pushing and we are still up there near the top and some of our direct rivals did not win this weekend."
It was a morale-boosting success for the team known as "Yellow Submarine" ahead of Thursday's Europa League Group E match at Viktoria Plzen.
Villarreal are already through to the last 32 of Europe's second-tier club competition and can make sure of top spot in the section with a win in the CzechRepublic.
Barcelona's lead at the top of La Liga was cut to two points when the Spanish and European champions conceded a late equaliser in a 1-1 draw at Valencia on Saturday.
Atletico are two points behind Barca in second after they won 2-0 at Granada, with Real Madrid a further two points adrift in third following their 4-1 victory at home to Getafe.
Real Sociedad continued their revival under new coach Eusebio Sacristan and climbed to 13th earlier on Sunday when two goals from Imanol Agirretxe gave the San Sebastian-based club a 2-1 comeback win at home to Basque rivals Eibar, who are ninth.