Colombia endured anxious moments but a towering header by centre-half Yerry Mina clinched top spot in Group H.
Mina struck 14 minutes from time, his second goal in as many games, to secure a place in the last 16 for the South Americans who will be dangerous opponents for either England or Belgium.
More than 20,000 Colombians inside the Samara Arena rejoiced but it was a moment of despair Senegal as they lost their place.
The Africans finished the group stage locked together on points and goals with Japan and were eliminated on the basis of their disciplinary record.
Still their supporters danced and swayed in the stands.
Until Mina’s goal, the noise and the colour of the crowd had been required to make up for a tense and disjointed affair on the pitch.
There was lots of rolling around. Lots of treatment required. Lots of pleading with the referee to do whatever he wasn’t doing.
Lots of eyes and ears were trained on how Japan were getting on.
The early exchanges were dominated by a referral to the video assistant referee after 17 minutes, after a tackle by Davinson Sanchez on Sadio Mane was ruled a foul and then overturned.
It was indisputable was that Mane was in on goal and preparing to shoot when the challenge came.
The challenge was desperate and last-ditch, made from behind and Sanchez seemed to be fishing hopefully for the ball.
At first glance, from the stands, it seemed to be a penalty and Serbian referee Milorad Mazic pointed to the spot.
Closer inspection of the slow motion replay from behind the goal, however, showed Sanchez making a clean contact on the ball, using a heel to poke it away from Mane.
It was unorthodox and some observers, including former England centre-half Terry Butcher, summarising on BBC Radio 5 Live, thought it was still a foul on the Senegal striker before taking the ball.
Mazic, however, having trotted across to the pitchside screen to see for himself, decided it was a fair tackle.
The referee returned to reverse his decision and restart with a drop ball.
Senegal edged the first half but Colombia threatened from two free-kicks taken by River Plate playmaker Juan Quintero.
Quintero went for goal with the first, a swerving left-footer which skidded off the turf and was pushed aside by goalkeeper Khadim Ndiaye, diving to his right.
Then, with the second, Quintero found the head of Radamel Falcao but the former Manchester United and Chelsea striker was unable to turn it on target.
Just over half an hour had gone when the South Americans lost James Rodriguez, the star of their team in Brazil 2014 who came into this World Cup carrying a calf injury.
James started the first game against Japan on the bench before returning to inspire the victory against Poland with two assists.
Whether he suffered a recurrence of the injury or was simply lacking the sharpness to influence the game was unclear but he was utterly dejected.
James sat on the turf before trudging off slowly. There was a consoling pat on the shoulders from Falcao but he walked straight down the tunnel.
By the second half he was out on the bench urging his team-mates on and Colombia improved after the interval, dominating possession.
Luis Muriel, who replaced James, saw a sweet strike deflected for a corner and another Falcao header flashed wide.
Senegal goalkeeper Ndiaye raced from his line to make a risky tackle on Muriel and won the ball, and had to be alert as central defender Salif Sane sliced a cross towards his own goal while attempting to clear.
Mina’s goal changed everything, climbing high at the near post to thump a powerful header into the goal from a corner.
Suddenly Senegal were in trouble and had to score.
David Ospina produced two good saves to preserve the lead. One from Mbaye Niang and then from Mina who almost scored in his own goal from a corner.
Ismaila Sarr miscued on the volley at the back post and Colombia closed out the win.