Winger Ismaila Sarr kept his cool to score a first half penalty and captain Kalidou Koulibaly netted a second goal as Senegal beat Ecuador 2-1 at the Khalifa International Stadium on Tuesday to earn a place in the last 16 of the World Cup.
Sarr scored his penalty in the 44th minute having earned the spot-kick himself, but Ecuador, who needed only a draw to reach the knockout rounds, equalised through Moises Caicedo.
That joy for the South Americans lasted only three minutes as Koulibaly restored Senegal’s lead and eased the pain of their losing out on the last 16 to Japan four years ago.
The African champions finish second in Group A with six points from three matches, one behind winners Netherlands and two ahead of Ecuador, whose tournament held much promise but has ended in disappointment.
Ecuador's players slumped to the turf in tears on the final whistle but in truth they were second best on the night and might have asserted themselves more in the first half.
Senegal dedicated their win to the memory of midfielder Papa Bouba Diop, goalscorer when they claimed a shock 1-0 win against France in 2002, and who passed away aged 42 two years ago to the day.
"This is for the family of Papa Bouba Diop," Koulibaly said. "We wanted to make him proud and give homage to him. He made me dream as a boy."
Senegal coach Aliou Cisse believes his side's run to victory in the Africa Cup of Nations final in Cameroon earlier this year had battled-hardened his players for games like this.
"We have a lot of experience under our belts as a team and that has helped us to prepare for these types of matches. I can only congratulate my players," he said.
"They are not children, they are adults and ready to step up to the mark. They all know exactly what is expected of them because they play football at a high level (with their clubs).
"They flew the flag high today and we are an African team going to the Round of 16. Football is an emotional game, it is a beautiful game."
The beating of African drums was constant, as was the effort and endeavour of Senegal, who dominated the opening period against an opponent happy to sit on the point they needed.
The decisive moment in the first half came late on when Sarr was ploughed into by Ecuador defender Piero Hincapie and picked himself up to convert the spot-kick.
The game's flow changed in the second period as it was Senegal who were happy to sit back and defend and a desperate Ecuador pressed for the equaliser.
It arrived midway through the half when Felix Torres flicked on a corner and Caicedo was unmarked at the back post to provide a simple finish.
The sizeable Ecuadorean support in the stands erupted in celebration. But that was halted shortly afterwards when Senegal struck again.
Ecuador failed to clear a corner and the ball fell kindly for Koulibaly to volley into the net from six yards.
"It is a hard blow. It is a big frustration that we are feeling," Ecuador coach Gustavo Alfaro said. "Unfortunately we made mistakes in the decisive match. And this leaves us with a bad feeling because we wanted to go through and stay on this road we had been following.
"The pain that we all feel right now is a huge pain. Unfortunately we were knocked out of a beautiful dream that these guys were building in the last two years. But we need to take into account the good performances we had and take that into the future."
Senegal will now want to at least match their quarter-final finish in 2002, when current coach Cisse was team captain.
They will play the top team from Group A in the last 16, which contains England, Iran, United States and Wales.
They will have to do without Gueye, who will be suspended after picking up his second yellow card of the tournament. (Reporting by Nick Said, Editing by Angus MacSwan)
The Bahraini royal, who has led the Asian Football Confederation since 2013, was elected at the Asian Football Confederation Congress in his home country
Sandeep Lamichhane is accused of raping a 17-year-old girl in a Kathmandu hotel room last August but was released on bail last month
The Sri Lankan leg spinner scalps three wickets to defend a modest total against the Sharjah Warriors
Indian have been drawn with hosts UAE, Malaysia and Kazakhstan in Group B of the Asian Badminton Mixed Team Championship
The win kept Capitals in the hunt for the play-offs, while the Knight Riders are out of the reckoning
Kieron Pollard's men beat the table toppers by 157 runs at Sharjah
India defeated England comprehensively by 7 wickets in the final in Potchefstroom to end their wait for a women’s world title