A close-range header in the first half was Aubameyang’s 11th goal in his past 14 games for Barca —— as many as he scored in his 34 prior outings in all competitions.
It proved to be enough to end La Real’s seven-game unbeaten league run at Reale Arena, with Alexander Isak and Alexander Sorloth wasting the opportunities that came their way.
Barca moved up to second while La Real were left six points adrift of fourth-placed Atletico Madrid with five games to play.
Defeat put a doubt on their credentials for achieving UEFA Champions League qualification.
La Real conceded their first goal at home in eight league matches in the 11th minute.
Gavi kept the ball alive after Ousmane Dembele hit the post and picked out Ferran Torres, who lifted a cross for Aubameyang to nod home.
Frenkie de Jong, Torres and Aubameyang all narrowly missed the target before Isak miscued when presented with a glorious chance to equalise on the stroke of half-time.
Barca were again let off the hook within two minutes of the restart when Sorloth blazed over from inside the six-yard box after a wonderful delivery from Adnan Januzaj.
There was a brief interruption due to objects being thrown in the direction of Gerard Pique from the stands.
The centre-back was the subject of their ire after controversial audio clips of him negotiating a deal to move the Supercopa de Espana to Saudi Arabia were released.
Pique played on after appearing to request a substitution in the first half but Barca lost Ronald Araujo to a knee injury in the 55th minute.
Sorloth and Januzaj were kept at bay by Marc-Andre ter Stegen and Gavi missed a chance to put the game to bed.
But Xavi’s team were able to hold on for an important three points.