It was going to be a mountain to climb for the Senegalese men that needed three points against an Ecuador side that was only playing for a point to make it into the last 16.
The first half was evenly matched till the decisive moment when Senegal were awarded the penalty after Ismaila Sarr was brought down in the box by Piero Hincapie.
Composed, Sarr stepped up and made no mistake from 10 yards to give the reigning African Champions the lead minutes before halftime in the 44th minute.
When it looked like Senegal were destined for victory, the match took an unlikely twist as Brighton and Hove Albion FC midfielder Moises Caicedo brought the South Americans back into contention for the knockout stage in the 67th minute from a Felix Torres provided the assist to make it 1-1.
But Senegal were not going to be behind for too long as Koulibaly responded 2 minutes later to restore parity and the desired goal was enough to send the west Africans into the knockout stage for the first time since 2002.
It was also the first time an African nation defeated a South American side at the World Cup since 1990 when Cameroon beat Colombia 2-1.
Meanwhile, in the other game, the Netherlands handed Qatar a 2-0 defeat to finish top of group A with 7 points.
The result also meant Qatar became the first individual host nation to lose all their group stage matches at the World Cup.