In a fascinating end-to-end encounter, the visitors struck the only goal of the game when Alejandro Garnacho burst through and fired into the corner to open his Red Devils account.
United weathered storm after storm and threw on the extra forward in Marcus Rashford as they went in search of the second goal they craved, but the change in shape seemed to hinder them, with Garnacho having looked particularly dangerous on the counter.
The visitor's performance arguably warranted more, but they were unable to break through in the second-half and now face a tough clash to progress with the likes of Juventus, Ajax and Barcelona all entering the tournament.
They weren't perfect, but United showed huge character to hold strong in an environment that bubbled and crackled with intensity. They were ruthless in both boxes, with a magical finish from Garnacho at one end and a breathtaking stop from de Gea at the other.
Despite a gritty display, the visitor's failure to win by a two-goal margin means Ten Hag's men could face a tricky fixture against a European giant to reach the second round, while star man Lisandro Martinez's booking means he'll play no part regardless.
Manager rating (out of 10, 10 = best)
Erik ten Hag, 7 -- Ten Hag has injected some much-needed fight into the Red Devils who gave everything their manager could have asked for. Quality in both boxes, bags of heart, and a desire to get the job done, but their hopes slowly fizzled out after changing shape.
Player ratings (1-10; 10 = best, players introduced after 60 minutes get no rating)
GK David de Gea, 8 -- Edged ever closer to breaking United's clean sheet record, and he was good value for it with a heroic double save to keep the baying hosts out, first through a full-stretch fingertip save before the rebound cannoned off his head and over.
DF Diogo Dalot, 7 -- Seemed to be targeted in the early stages as the Spanish outfit built a flurry of attacks on the left, but he stood up to the task really well. A steady performance overall against a side that refused to tire.
DF Victor Lindelof, 8 -- Got the nod over Harry Maguire alongside Lisandro Martinez and made an important block in to steer Mikel Merino's effort wide of goal. Covered Dalot well in a resolute United display. Withdrawn shortly after the break.
DF Lisandro Martinez, 9 -- What a performance. Showed his class to bully the Sociedad forward and nick back possession, before pinging his clearance off a blue shirt and out for a goal kick. Thwarted Sorloth with an exceptional block after the restart. Immense all over.
DF Luke Shaw, 8 -- Responded with a gritty challenge of his own after a big tackle from a Sociedad shirt roused the home faithful, and that set the tone for his performance. Received a talking to for a professional foul that halted a Sociedad break, but it was probably worth it.
MF Casemiro, 7 -- The £70million man put himself about and found himself on the end of a couple of sore challenges as a result. A vital cog as the visitors held strong against a barrage of attacks.
MF Christian Eriksen, 7 -- A typical Eriksen performance. Cool and composed, picked his passes well, and positioned himself in good areas when protecting his back four. Replaced in the second half.
MF Bruno Fernandes, 8 -- The Portugal man was deployed on the right in an intriguing move. He sprayed the ball across the turf like the groundsman's best sprinkler and ran his socks off all night, while it was his header that started the move leading to the goal.
MF Donny van de Beek, 6 -- Found it tricky to make a big impact having played so few minutes this season, although he exchanged some neat one-twos to try and open the hosts up.
MF Alejandro Garnacho, 9 -- Electric in the first half, but he seemed to be taken out of the game by United's change in shape. Opened the scoring with a cracker when he chased onto Ronaldo's pass and produced a clinical finish into the corner. A memorable moment for him.
FW Cristiano Ronaldo, 7 -- Linked up really nicely with Garnacho. Showed his quality when he spotted the winger's run to assist the opener and turned a slick pass around the corner to send the youngster away again. Lifted a glorious chance onto the roof of the net.
DF Harry Maguire, NR -- Harry Maguire, the centre-back turned centre-forward, you heard it here first. He did his best to make a nuisance of himself as United went direct, but he couldn't find a leveller.
MF Scott McTominay, 6 -- The fiery Scot is normally in the thick of everything, so this was a quiet display from him by all accounts.
MF Fred, NR -- Provided Fresh legs in the latter stages of the contest.
FW Marcus Rashford, 6 -- Replaced Van de Beek and wasted no time in driving at the Sociedad defence, but he had the ball nicked away from him.