The hosts had to rely on a last-minute winner from Marouane Fellaini to seal victory as the new manager oversaw his first game at Old Trafford.
The hosts had to rely on a last-minute goal from Maroune Fellaini to overcome their dogged Spanish opponents, with Wayne Rooney missing a first-half penalty.
Darren Fletcher put United ahead soon after the restart, only for Rodrigo Moreno to level matters after capitalising on a poor attempted clearance by Tom Cleverley.
And Van Gaal was not impressed by his side's showing ahead of its Premier League kickoff against Swansea City on Saturday.
"The main thing is we won, despite playing our worst game [so far in pre-season]," he told the club's official website.
On his first game at Old Trafford, Van Gaal added: "I enjoyed it. Coming onto the pitch, the fans are shouting and screaming your name."
Jonny Evans, Luke Shaw and Antonio Valencia all sat out the game as they continue to struggle for fitness ahead of the new season, and Van Gaal was sceptical when questioned on their respective bids to face Garry Monk's side.
He added: "We have to wait to see if they can play on Saturday."