A powerful header from Barcelona's Yerry Mina fired Colombia into the last 16 of the World Cup with a 1-0 win over Group H rivals Senegal, who crashed out due to a poorer disciplinary record than Japan.
Colombia and Japan will play either England or Belgium, who were playing later Thursday.
The South Americans, looking to reach the latter stages after reaching the quarter-finals in Brazil, risked going out of the tournament at the first hurdle.
But after seeing the video assistant referee come to their rescue in a disappointing first half, Colombia were handed a last-16 lifeline 13 minutes from the end when Mina rose to meet a corner from the right and direct a header into the roof of Khadim Ndiaye's net.
Poland's 1-0 consolation win over Japan meant the Asians finished level with Senegal, who were agonisingly eliminated because they were issued six yellow cards in the competition, two more than Japan.
In Samara, Colombia coach Jose Pekerman kept faith with the attacking front line that thumped Poland 3-0, with midfielders Juan Quintero, James Rodriguez and Juan Cuadrado providing the support for striker Radamel Falcao up front.
But by the end of an entertaining first half, Pekerman was forced to tinker when Rodriguez was forced off with an injury problem and replaced by Luis Muriel. Before then, Senegal had shown attacking potency but, all too often, failed to threaten David Ospina's goal.
Colombia's best first-half chance came from a free-kick that saw Ndiaye dive to parry Juan Quintero's powerful effort after Falcao had been sandwiched in mid-air. Yet Colombia lacked pace and punch, and the trickery of Juan Cuadrado, so effective against Poland, failed to impress Senegal as they caught the Juventus man out more than once.
When Cuadrado lost possession cheaply at the halfway line, Keita Balde sent Sadio Mane on his way towards goal before the Liverpool man fell under a challenge from defender Davinson Sanchez.
Serbian referee Milorad Mazic pointed to the spot but amid Colombian protests he was called to consult the VAR, which showed Sanchez's boot had made contact with the ball first.
From another free kick Falcao was flagged offside when he headed Quintero's floated delivery high and wide.
Senegal responded, but Keita shot straight at Ospina after the 'keeper had spilled a powerful drive by Mane.
There was excitement among the Colombian fans when they learned Poland had scored against Japan, but Los Cafeteros struggled to do their bit. Hopes were raised when Quintero's powerful free kick from the right was blocked in the area and fell to Muriel, whose shot was deflected out. From the corner, Falcao's header was bundled wide.
Penalty claims were waved away when Muriel fell dramatically under a challenge by Ndiaye as the 'keeper rushed out to close him down. But the Samara stadium erupted as Colombia finally broke the deadlock.
Cuadrado's attempt to dribble into the area earned a corner, and Barcelona defender Mina rose highest to flash a header downwards that bounced up into the top of Ndiaye's net on 77 minutes.
Senegal rallied in the closing minutes and it took a series of great saves by Arsenal shot-stopped Ospina to keep Colombia in the tournament.