Colombia's Yerry Mina thumped home a second-half header to secure a dramatic 1-0 victory over Senegal on Thursday that catapulted the South Americans into the World Cup last 16 and dumped their African opponents out of tournament.
Senegal had only needed a point in their final Group H game to reach the next round, but defeat saw them miss out to Japan, who edged them out of the runners-up spot by virtue of having a better disciplinary record.
It was the first time in World Cup history that two teams had been separated by the amount of yellow cards they had accrued in the tournament.
Both Senegal and Japan, who were beaten 1-0 by Poland on Thursday, finished the group with four points and an identical record in all other respects. Yet the Asian side ended in second position having picked up four yellow cards to Senegal's six.
Colombia, who finished as group winners with six points will face a last-16 match against the runners-up in Group G where England and Belgium battle for supremacy later on Thursday.
Defeat for Senegal eliminated them at the group stage in their first World Cup appearance since 2002, and left Africa without a representative in the knockout stages.
Senegal had been heading through until the 74th minute when Mina rose to meet a corner and sent a bullet header into the net.
It was a crushing blow to the Senegalese who had been the better side for most of the game and had a penalty award overturned in the first half after a VAR review.
They had looked set to take the lead in the 17th minute when Liverpool forward Sadio Mane went down in the area under a challenge from Davinson Sanchez and referee Milorad Mazic pointed to the spot.
The VAR system has not been universally acclaimed at this tournament, but television replays appeared to show Sanchez get his heel on the ball, before clattering into Mane, and after reviewing his original decision, Mazic agreed.
Colombia had got off to a poor start and suffered a blow early on when playmaker and talisman James Rodriguez was forced off injured.
After his display in their last match against Poland, Colombian hopes had again been pinned on the shoulders of Rodriguez, who had spearheaded their run to the last quarter-finals four years ago.
Those hopes looked forlorn, however, within minutes of kickoff at the Samara Arena as the forward was hit with one heavy challenge, which clearly took its toll, and he was withdrawn after half an hour having spent much of the intervening period ambling around the pitch.
His exit did little, however, to revive the sluggish South Americans, who had been second best in almost every department.
Chances throughout the game were thin on the ground, with Colombia striker Radamel Falcao heading off target in the 25th minute and again in the second half, while substitute Luis Muriel had an effort blocked.
Yet Mina ensured Colombia were not made to pay when he headed home in the 74th minute.