Inter have failed to get beyond the Champions League group stage for a second successive season after losing 2-1 at home to Barcelona, with Ansu Fati's late victor making him the youngest scorer in the competition's history.
Fati, 17, came on as an 85th-minute substitute, and a minute later scored from Luis Suarez's pass.
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.
Inter threw everything at Barcelona, who had already qualified, after Romelu Lukaku cancelled out Carles Perez's opener, but the victor came from 17-year-old substitute Fati in the 86th minute.
However, Dortmund won 2-1 at home against Slavia Prague to finish second, with Inter coming third.
Ansu Fati raises his fist to crowd after celebrating his goal with teammates.
"Messi getting rest. Nothing more", Valverde said.
In the process, Fati broke a record previously held by Peter Ofori-Quaye, who scored for Olympiacos aged 17 years and 194 days in 1997.
Martinez thought he had found the breakthrough when he chested down a through ball and fired home, before being denied by the offside flag, and Inter again had a goal chalked off when Lukaku was in an offside position before Martinez prodded in from close range.
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).