Both sides were already assured of progress from Group E ahead of the San Sebastian showdown, but September's shock Old Trafford defeat to the LaLiga side meant United travelled to Spain in second spot.
Garnacho's superb goal got the Red Devils off to a dream start as they sought to usurp the hosts, but they struggled in the second half as Sociedad held tight for a 1-0 loss that means they top the group on goal difference.
Erik ten Hag's runners-up will now have to play an extra round in mid-February against a side dropping out of the Champions League, with Barcelona, Juventus and his former club Ajax among the potential opponents.
La Real progress straight to the last-16 on a night that was only 17 minutes old Garnacho overtook George Best as United's youngest non-English goalscorer in European competition with a lovely finish.
Cristiano Ronaldo provided a fine assist for the 18-year-old's first senior goal and lifted narrowly over towards the end of a first half that ended with David De Gea producing an excellent double save.
But Ten Hag's side were unable to build on that solid start, with defender Harry Maguire brought on as makeshift striker in a desperate - and ultimately fruitless - attempt to snatch the second goal they needed.
The road to May's Europa League final in Budapest got harder with this result and United will find out their play-off opponents on Monday.
Garnacho, Donny van de Beek and Victor Lindelof came into the side at the Reale Arena, where the injury-hit hosts started brightly and Carlos Fernandez struck into the side-netting unaware he had strayed offside.
United settled after that scare and Ronaldo was soon getting under the skin of the locals, who whistled him as his penalty claim against Robin Le Normand was ignored by the officials.
The 37-year-old looked frustrated but his mood improved in the 17th minute.
Bruno Fernandes headed on a long kick forward by De Gea to Ronaldo, who sent a superbly-weighted pass through for Garnacho to drive down the left and fire home the opener.
The 18-year-old's first goal for United was ratified by the VAR after checking Fernandes had not strayed offside.
Ex-Newcastle midfielder Mikel Merino saw a shot blocked as Real tried to equalise, but United stood firm and looked more likely to score a second.
Garnacho slipped at just the wrong moment after some nifty footwork and Ronaldo looked shocked after missing a bigger chance in the 42nd minute.
The frontman forced a mistake from Jon Pacheco as he attempted to deal with a long pass, but the former Real Madrid star lifted over goalkeeper Alejandro Remiro and crossbar from just inside of the box. No offside was signalled.
Real were creating precious little but De Gea was called into action just before the break.
The long-serving United goalkeeper produced a one-handed stop to deny Andoni Gorosabel's dipping half-volley from 20 yards, then spread himself well to stop Pablo Marin turning in the rebound from a narrow angle.
The home side returned from the break reinvigorated but were struggling to seriously test De Gea, whose outfield team-mates were starting to lose their way.
Ten Hag turned to Marcus Rashford and Scott McTominay - the midfielder surprisingly replacing centre-back Victor Lindelof - but it did not have the desired effect.
Imanol Alguacil's hosts were smartly slowing the game down and desperate United even brought centre-back Maguire on as an attacker.
Still the visitors toiled and Casemiro saw a shot saved in a 90th-minute melee that was eventually halted by a delayed offside flag.
Five minutes of stoppage time came and went as United won in Spain but lost the battle for top spot.