But Barca’s run-in could be hampered after their defence was almost completely wiped out by injuries at Anoeta, with Dani Alves, Ronald Araujo and Gerard Pique all going off with problems while Jordi Alba appeared to play on in discomfort.
Victory leaves Xavi Hernandez’s side second, six points clear of Real Betis in fifth, with a game in hand, and two ahead of Atletico Madrid in fourth. Atletico were held to a goalless draw by Granada on Wednesday.
Sevilla sit third after they held on for a 3-2 win away at Levante, Tecatito scoring twice in Valencia.
Real Sociedad might have had an outside chance of joining the race for the top four if they had beaten Barcelona but defeat surely leaves them looking to secure a spot in the Europa League. They are six points behind Atletico in fourth.
Aubameyang’s goal was his 11th for Barca since he joined the club in January and this one was particularly important, with his team eager to overturn an unexpected dip in form.
Xavi challenged his players on Wednesday to escape the “negative dynamic” after back-to-back defeats by Eintracht Frankfurt in the Europa League and Cadiz at Camp Nou.
There was controversy off the pitch too, as Pique found himself in the middle of a media storm this week after leaked audio messages revealed unseemly conversations with the president of the Spanish football federation, Luis Rubiales.
The leak by El Confidencial reported how the federation negotiated 24 million euros in commission to be paid to Pique’s events company, Kosmos, in return for the Spanish Super Cup being moved to Saudi Arabia.
Pique’s early touches were whistled by the Real Sociedad crowd, who jeered again when the 35-year-old was substituted in the 82nd minute.
Alves had already gone off in the 66th and Araujo in the 55th, with Barca now crossing their fingers the problems are not serious.
The decisive moment, though, came in the 11th minute as Ousmane Dembele hit the post when left free in the area. The ball cannoned out and La Real looked safe to clear until Gavi robbed the ball back, chipped it to Ferran Torres, whose looping ball across allowed Aubameyang to nod in.
Real Sociedad might easily have grabbed an equaliser but kept running into the Marc-Andre ter Stegen, who enjoyed an inspired night in the Barcelona goal.
Alexander Isak went close while Alexander Sorloth missed La Real’s best chances, firing wide at the back post from Nacho Monreal’s cross and then taking too long after being picked out in the area by Adnan Januzaj.
Sorloth had another sight of goal late on, but his finish from the angle was brilliantly stopped by Ter Stegen, this time his left foot allowing Barca to hold on for an important victory.