Earlier, Barca had momentarily usurped Real thanks to Lionel Messi's winner four minutes from time in a 2-1 victory at Atletico Madrid.
Real lead Barca by a point, but also have a game in hand on their title rivals.
"We showed character to turn the game around," said Real boss Zinedine Zidane.
"With everything that happened today it was vitally important to get the three points."
Bale was recalled to the starting line-up for the first time in three months after a long-term injury layoff and Real's shock 2-1 defeat to Valencia in midweek.
Firstly, Manu Trigueros volleyed home Samu Castillejo's knockdown before Cedric Bakambu burst onto Bruno Soriano's through ball to slot past Keylor Navas.
Ronaldo almost replied immediately, but Madrid's luck looked out when his sweetly struck volley came back off the post.
However, Bale started Madrid's fightback as he rose highest to power home Dani Carvajal's cross 25 minutes from time.
Villarreal had enjoyed the better of the opening hour, but were swamped by wave upon wave of Real attack for the final 30 minutes.
Ronaldo took responsiblity from the spot to smash home the equaliser.
Villarreal had lost goalkeeper Sergio Asenjo midway through the first half to what looks like the fourth cruciate knee ligament injury of his career.
"Asenjo seems to have torn his ACL (anterior cruciate ligament) in his left knee. It's a real shame," said Villarreal coach Fran Escriba.
And his absence was to prove crucial for Real's winner seven minutes from time as substitute goalkeeper Andres Fernandez let Alvaro Morata's powerful header from Marcelo's cross squeeze under his body to complete a rousing Real fightback.
===================
Messi stabbed home at the second attempt after his first effort was blocked to register his 27th career goal against Atletico.
"It was a terrible pitch for passing the ball, but I think it favoured us for both the goals," said Enrique.
Rafinha's scrappy effort fired Barca into the lead just after the hour, but Atletico responded seven minutes later through Diego Godin.
Defeat leaves fourth-placed Atletico just one point clear of Real Sociedad in the battle for the final Champions League slot.
"We competed very well, but they showed their class in both areas," said Atletico coach Diego Simeone.
The change in tactics did little to stem Barca's slump in form early on as Atletico dominated the opening half hour.
Atletico's best effort of the opening half came from long range, though, as Antoine Griezmann's driven effort on his weaker right foot forced a brilliant flying save from Marc-Andre ter Stegen.
Luis Suarez screwed horribly wide after being played in by Messi at the start of the second-half.
The deadlock was eventually broken in scrappy fashion on 63 minutes as Rafinha profited from a loose ball inside the area to fire low into the far corner.
However, the lead lasted only seven minutes as Godin rose higher than a host of Barca defenders to flick home Koke's free-kick for the equaliser.
Yet, when Barca needed a potential season-defining goal, Messi again came up trumps with his 35th in as many games this season.
The five-time World Player of the Year's first effort from Suarez's cut-back was blocked, but he followed up to prod past the helpless Jan Oblak and move Barca top of the table for a few hours.
You’ve reached your limit of {{free_limit}} free articles this month.
Subscribe now for unlimited access.
Already subscribed? Log in
Subscribe to read the full story →
Smart Quarterly
₹900
3 Months
₹300/Month
Smart Essential
₹2,700
1 Year
₹225/Month
Super Saver
₹3,900
2 Years
₹162/Month
Renews automatically, cancel anytime
Here’s what’s included in our digital subscription plans
Exclusive premium stories online
Over 30 premium stories daily, handpicked by our editors


Complimentary Access to The New York Times
News, Games, Cooking, Audio, Wirecutter & The Athletic
Business Standard Epaper
Digital replica of our daily newspaper — with options to read, save, and share


Curated Newsletters
Insights on markets, finance, politics, tech, and more delivered to your inbox
Market Analysis & Investment Insights
In-depth market analysis & insights with access to The Smart Investor


Archives
Repository of articles and publications dating back to 1997
Ad-free Reading
Uninterrupted reading experience with no advertisements


Seamless Access Across All Devices
Access Business Standard across devices — mobile, tablet, or PC, via web or app
