A brace from Mariano and a close-range strike from Jesus Vallejo ultimately gave the home side all three points, although Villarreal were on level terms through Gerard Moreno and created numerous chances before Jaume Costa scored in the fourth minute of injury time.
Despite Karim Benzema being ruled out through injury, Bale was deemed surplus to requirements by head coach Zinedine Zidane, fuelling speculation that the Welshman will leave Madrid in the summer.
Real were looking to bounce back from a stunning 1-0 defeat at lowly Rayo Vallecano last week and, with nothing at stake for his side, Zidane made a number of changes and was rewarded with a goal after only two minutes.
Former Arsenal midfielder Santi Cazorla dawdled in possession deep in Villarreal's half, allowing Brahim Diaz to nip in and tee up Mariano, who got between two defenders to stab home.
Villarreal had taken 10 points from their previous four fixtures to catapult themselves away from the relegation zone but they were being penned back by a rampant Real.
Goalkeeper Andres Fernandez saved well from Mariano and Lucas Vazquez before the Yellow Submarine equalised.
Casemiro was dispossessed before Moreno thumped high past Real goalkeeper Thibaut Courtois.
Dani Carvajal saw his first-time strike from distance clatter the post as Real looked to restore their advantage but Courtois had to be alert to deny Samuel Chukwueze at the other end.
Villarreal were competing on even terms as half-time approached but they fell behind five minutes before the break, Jesus Vallejo scoring from close range after Marcelo's strike had deflected into his path.
Real looked to have put the game to bed when they moved 3-1 ahead early in the second half, Carvajal's superb low cross leaving Mariano with the simple task of steering the ball into the net at the far post.
However, Villarreal were desperate to ease their lingering relegation fears and Chukwueze twice flashed shots just wide of the post when he could have done better and Moreno brought a good save from Courtois.
Mario Gaspar also glanced a header beyond the post from Cazorla's corner but it took until the last few seconds of added time before Moreno set up Costa on the edge of the area to curl a superb left-foot shot beyond a helpless Courtois into the top corner.
Amazingly there was still time for the visitors to create a chance for the equaliser, but Xavier Quintilla could only fire into the side netting with the last kick of the game.