But it was still enough to top Group C and set up a quarterfinal meeting with Ivory Coast on Saturday.
Mikel Merino, one of three permitted players older than 24, swept in Spain’s goal in the 66th minute in Saitama after being set up by Marco Asensio.
There was an equalizer in the 87th — Tomas Belmonte’s header went in off goalkeeper Unai Simón’s right knee — but Argentina lacked the time to conjure the required win to avoid early elimination.
Instead, Egypt took second place in Group C after Yasser Rayan and Amar Hamdi clinched a 2-0 win over Australia, which had beaten two-time gold medalist Argentina in the opening game.
Egypt’s quarterfinal is against defending champion Brazil, which sealed first place in Group D with a 3-1 victory over Saudi Arabia.
Richarlison, who was allowed to come to Japan by Premier League club Everton despite not being mandatory, scored twice to add to his hat trick from the opening win over Germany.
There will be no second youth title this summer for Germany, which won the under-21 European Championship last month. The 2016 Olympics silver medalists are going home early.
Ivory Coast, who reached the quarterfinals at its previous Olympic appearance in 2008, will be staying longer as well this time. A 1-1 draw with Germany was enough to take second place in Group D. Benjamin Henrichs scored an own-goal in the 67th minute to give the Ivorians the lead. Eduard Löwen equalized six minutes later from a free kick.
France leaves after another heavy loss, beaten 4-0 by Japan. The host nation had the only perfect record in the group stage with three wins. France conceded the most goals — 11 — across the four groups.
Takefusa Kubo, the 20-year-old forward signed up to Real Madrid, is having a dream Olympics. He netted to the opener just like in the previous two matches. Hiroki Sakai, Koji Miyoshi and Daizen Maeda were also on target for Japan, which was already leading 3-0 when France had Randal Kolo Muani sent off with around 20 minutes to go.
Mexico recovered from losing to Japan to beat South Africa 3-0 and secure a quarterfinal with South Korea, which routed Honduras 6-0 to top Group B.
New Zealand drew 0-0 with Romania to hold off its opponent on goal difference to finish second and go through to a clash with Japan.
More AP Olympics: https://apnews.com/hub/2020-tokyo-olympics and https://twitter.com/AP_Sports