Villa eye for goal undimmed by lengthy layoff
With Barca in danger of dropping their first points of the campaign, the 30-year-old drove into the penalty area deep into added time and crashed a left-foot shot high past Andres Palop to complete a stirring fightback from two goals down.
The victory, in which Cesc Fabregas netted a double, extended the La Liga leaders' perfect record and equalled their best start to a domestic season of six straight wins.
"I am very happy to be able to help the team in this small amount of time in a very difficult match," Villa told reporters.
"A goal is always important but when it serves to help your team, like today, in the form of points, against a very tough opponent who was in front for a long time, it becomes even more crucial," added Spain's record scorer, who broke his leg at the Club World Cup last December.
"It's very difficult to win here, and all the more so to come from behind, but Barca battled and that's why we got three vital points."
Barca coach Tito Vilanova has used Villa sparingly since his return but may increasingly opt for the former Valencia man ahead of Chile forward Alexis Sanchez, who is yet to find his form this season.
Villa has developed a fine understanding with Barca's World Player of the Year Lionel Messi and can feed off the creative play of Spain midfielders Xavi, Andres Iniesta and Fabregas.
Before hosting champions Real, Barca play at Portuguese side Benfica in Champions League Group G on Tuesday.