Manchester United had to settle for second place in the group after Alejandro Garnacho scored an outstanding goal.
They needed to win by two goals or more in Spain to finish top of the group and their spirits were lifted when Garnacho scored.
It was a great moment for the 18-year-old, who was making his second start for Manchester United.
David de Gea produced a double save to keep out Andoni Gorosabel and Pablo Marin after a great chance byRonaldo to double the lead.
With a superior goal difference, Sociedad advance to the last 16 with a superior goal difference.
The knockout-round play-offs will take place in February next year, with one club dropping down from the league.
Over the course of two legs, they could meet teams like Barcelona and Shakhtar.
The draw will take place on Monday.
Had United scored one more goal, they would have won the group and avoided two extra games.
They were in complete control in the first half, but failed to score in the second, and ended the match with Harry and Marcus up front, along withRonaldo.
Garnacho was 18 years and 125 days old when he became United's youngest non-English scorer in Europe.
The Argentina youth international scored a late winner for United's under-21 side.
In San Sebastian, Garnacho showed what a talent he is with a composed 17th-minute finish after receiving a well- timed pass outside the penalty area before finishing inside the box.
The youngster was given another chance but he slipped and fired over the bar.
David Silva is a four-time premier league winner with Manchester City.
They finished top of the group in a game that saw a lot of yellow cards.