Sarr converted a penalty on the stroke of halftime but Brighton midfielder Moises Caicedo put his side on level terms with a close-range finish in the 67th minute. Koulibaly wrested back the lead for Senegal by thumping home a first-time effort 20 minutes from time.
The result at Khalifa International Stadium means Senegal finish second in Group A with six points from three matches. Ecuador miss out on a place in the last 16, having finished two points further back in third place.
Senegal showed their attacking intent in the third minute when Idrissa Gueye latched onto Ismail Jakobs' cross from the left flank. But the Everton midfielder could only manage to pull his first-time effort wide of the post.
Joyous scenes in Senegal after the reigning AFCON Champs defeat Ecuador 2-1 in a must-win game to advance to the Round of 16 for just the third time in the nation’s history.
Flags. Flamethrowers. And Dancing in the Streets. ����
Youssouf Sabaly then released Boulaye Dia with a clever through ball only for the Villarreal forward to flash his shot harmlessly out of play. Ecuador looked frazzled as Senegal continued to bombard the South American team's defense.
Sarr provided another tense moment for Gustavo Alfaro's men when he ran onto Pape Gueye's headed flick and made a probing run into the box before bending an effort just beyond the far post. Pathe Ciss let another chance slip by heading over the bar after a curling Jakobs free-kick from the right wing.
Ecuador struggled to advance into their final third as Caicedo, Carlos Gruezo and Alan Franco were suffocated by Senegal's high-pressing back four.
Senegal were finally rewarded for their dominance when Sarr was awarded a penalty, having been bowled over by Piero Hincapie in a race for the ball inside the box.
Today marks two years since the passing of the incredible Pape Bouba Diop who scored Senegal’s ���� first ever World Cup goal and it was enough to stun defending champions France ���� at the 2002 edition.
The Watford winger coolly slotted the resultant spot-kick into the bottom right corner, leaving goalkeeper Hernan Galindez planted to the middle of his line.
Ecuador began the second half with a greater sense of urgency, moving the ball more fluently and forcing Senegal to defend deeper. Pervis Estupinan created a rare chance for his team as he sent a sumptuous cross into the path of Michael Estrada, whose header missed the target.
Ecuador equalized when Felix Torres leapt highest to flick on Gonzalo Plata's silken delivery from a corner. Caicedo was free at the far post and poked a shot past a flat-footed Edouard Mendy.
The intensity was suddenly at fever pitch and Senegal restored their lead three minutes later when Gueye's cross rebounded off Torres' shoulder. Koulibaly was first to react and hammered an unstoppable volley past Galindez.