The 17-year-old Guinea-Bissau-born attacker picked up a Luis Suarez cross to fire home four minutes from time to become the youngest player to score in the Champions League.
Barcelona were already through to the knockout stages as Group F winners and left six-time Ballon dOr winner Lionel Messi at home.
But Serie A leaders Inter needed a win over the La Liga leaders or to match Borussia Dortmunds result at home to Slavia Prague to qualify on their superior head-to-head record.
Instead the Germans made it through to the knockout rounds with a 2-1 win to finish three points ahead of third-placed Inter, who go into the Europa League.
Debutant Carles Perez had put the Spaniards ahead after 23 minutes at the San Siro, but Romelu Lukaku drilled in a equaliser just before the break to keep the hosts in the tie.
Inters strike duo Lukaku and Lautaro Martinez had three goals ruled offside between them, two for the Argentine who has already scored five times in the competition this...