In another must-win match in Qatar, Senegal took the lead after a first-half penalty from Ismaila Sarr. Moises Caicedo then scored for Ecuador to make it 1-1 in the 67th.
Ecuador would have advanced from Group A with a draw and Senegal would have been eliminated.
The Netherlands beat Qatar 2-0 in the other match to win the group. Senegal finished second while Ecuador and Qatar were eliminated.
Senegal last advanced from the group stage at the 2002 World Cup, when the team reached the quarterfinals in their tournament debut and its only other appearance at the event.
Sarr was knocked over by a clumsy challenge from Ecuador defender Piero Hincapie for the penalty just before halftime. He side-footed his shot into the bottom right corner in the 44th minute and almost the entire Senegal bench and coaching staff ran to celebrate with him near the corner flag.
Senegal now has a chance to match, or even better, its scintillating run to the quarterfinals in 2002, when current coach Aliou Cisse was the captain and the team matched Africa’s best performance at a World Cup.
The game against Ecuador at Khalifa International Stadium fell on the second anniversary of the death of Papa Bouba Diop, the popular player who scored the goal in Senegal’s 1-0 victory over defending champion France in the opening game of the 2002 World Cup.
To mark it, Koulibaly had the number 19 written on his captain’s armband — Diop’s shirt number when he played for Senegal.