Teenager Ansu Fati became the youngest goalscorer in Champions League history as Barcelona ended Inter Milan’s hopes of reaching the last 16.
Fati, 17, came on as an 85th-minute substitute, and a minute later scored from Luis Suarez’s pass.
Barcelona, already qualified, took the lead through Carles Perez’s close-range goal on his Champions League debut.
Romelu Lukaku equalised with a low 25-yard strike but Fati’s late winner consigned Inter to the Europa League.
“I played the give and go with Luis and when I scored the stadium just went silent. I’m super-happy,” said Fati, who has represented Spain at under-21 level.
“It’s a dream. Everything seems to be going at high speed. I just have to take every opportunity I’m given. But here, you look around and think: ‘what have I done’?”
Barcelona boss Ernesto Valverde praised the striker’s finishing ability and said: “Ansu is a born scorer and although he’s had some niggling pain, we wanted him to have some minutes.
“That it’s a Barca lad who’s the youngest ever scorer in this competition delights us.”
The Italians started the day second in Group F and needed to match Borussia Dortmund’s result to advance to the knockout phase of the Champions League for the first time since 2011-12.
However, Dortmund won 2-1 at home against Slavia Prague to finish second, with Inter coming third.
“Watching that Ansu Fati goal is painful, as it killed us in every way,” said Inter boss Antonio Conte.
“We were pushing, creating the chances to score and go 2-1 up. I was also disappointed for the fans at San Siro, as they pushed us from start to finish and created a wonderful atmosphere. It should’ve ended differently.
“We deserved more in this group. Still, it’s all valuable experience. We have to raise our heads again.”
Barcelona rested Lionel Messi, while Suarez began on the bench, and there was also a first Barca appearance for Brazil goalkeeper Neto following a £23.3m summer move from Valencia.
Neto saved efforts from Cristiano Biraghi and Lautaro Martinez and a number of shots from Lukaku.
Martinez twice had the ball in the net in the second half, but was ruled offside on both occasions.
Fati had scored two La Liga goals for Barcelona this season and made two substitute appearances in the Champions League before this match at the San Siro.
At 17 years and 40 days old, he replaces previous record holder Peter Ofori-Quaye, who scored for Olympiakos against Rosenborg on 1 October 1997 at the age of 17 years and 195 days.
“We feel obliged to win this competition and we want to win every single match,” added Valverde.
“We’re thrilled because Inter are a really demanding rival. We played to win and my players, many of whom were making a debut of some kind, responded by showing competitive mettle.”
Inter miss out again – the stats
Inter Milan have been eliminated at the group stage in their last three appearances in major European competition, going out in the same stage of the 2016-17 Europa League and last season’s Champions League.
Barcelona have become only the second side to avoid defeat in 20 consecutive Champions League group stage games (won 14, drew six), after Real Madrid between 2012 and 2017 (30 matches).
Inter boss Antonio Conte has failed to progress from the group stages in two of his four Champions League seasons as a manager (also in 2013-14 with Juventus).
This was Barcelona’s first win away at Inter in any European competition since September 1959 in the Inter-Cities Fairs Cup quarter-final (4-2).
Aged 21 years and 297 days, Carles Perez is the youngest Spaniard to score on his Champions League debut for Barcelona since Cristian Tello (20 years 209 days) v Bayer Leverkusen in March 2012.
Inter’s Romelu Lukaku has scored in back-to-back Champions League games for only the second time, and the first since his first two appearances in the competition for former club Manchester United in September 2017.