Kalidou Koulibaly's winner was his first goal for Senegal in his 67th international cap for his country
The win means Aliou Cisse's side finish second in Group A, setting up a last-16 meeting with Group B winners England on Sunday (19:00 GMT).
All three goals came from players based in England as Ecuador's Brighton midfielder Moises Caicedo cancelled out a penalty by Watford's Ismaila Sarr before Chelsea defender Koulibaly's side-footer won it.
Ecuador needed just a point to progress but paid the price for a passive display as Senegal were spurred on by an almost non-stop cacophony of drumming from their supporters in Al Rayyan.
Watford winger Sarr coolly stroked home from the spot, after being clumsily upended by Ecuador defender Piero Hincapie, to put the African champions deservedly ahead.
Ecuador levelled with their first real chance as Caicedo swept home Felix Torres' flick-on but Koulibaly's composed finish immediately regained the lead for Senegal, who knew only victory would be enough to go through barring an unlikely Qatar upset against the Netherlands.
They held out amid a nervy six minutes of stoppage time to finish as runners-up in the group behind the Dutch, who clinched top spot by handing the tournament hosts a third defeat in three games with a comfortable 2-0 win in Al Khor.
Much has been made of the absence of Senegal talisman Sadio Mane from this tournament through injury but they have found goals from elsewhere, their five thus far in Qatar all coming from different players.
They found swathes of space in and around the Ecuador area early on as the South Americans began nervily but Everton's Idrissa Gueye and Boulaye Dia both dragged excellent opportunities wide.
But Sarr, who had missed his two previous penalties for his club, showed composure from the spot to slot his side in front and their heads did not drop even when Caicedo levelled from a corner.
Victory secured a first last-16 appearance since 2002, when they shocked France in the opening game on their way to the quarter-finals and, before the game, Senegal dedicated their efforts to former Fulham and Portsmouth midfielder Papa Bouba Diop - scorer of the famous winner against the French - who died, two years ago to the day, in 2020 aged 42.
Koulibaly, who paid tribute by penning 19, Bouba Diop's old shirt number, on his captain's armband, said he would give his man-of-the-match award to the late midfielder's family.
"We wanted to pay homage to him, he made me dream when I was a boy," said the 31-year-old.
"We knew we wanted to play in his honour, this wasn't something we were going to let slip. This was a special day for Senegal."
Senegal became the first African team to beat a South American side at the World Cup since Cameroon against Colombia in 1990, ending a 21-game winless run in such meetings, and are only the third African nation to reach the knockout stages on two or more occasions, emulating Nigeria and Ghana.
They will, however, be without influential midfielder Gueye, for the second round - and what would have been his 100th cap - after he picked up a second yellow card of the tournament.
Many Ecuador players lay prostrate on the pitch at the final whistle, some in tears, devastated at letting slip their chance of progression - like Senegal they had only once previously negotiated the group stages - and a face-down, clearly distraught Caicedo had to be physically hauled from the turf by team-mates.
Ecuador had rightly earned plaudits for their opening two games, having brushed aside Qatar and arguably been the better side in their 1-1 draw with the Dutch - but they failed to reproduce that level of performance under the pressure of a virtual winner-take-all environment.
Boss Gustavo Alfaro risked joint leading World Cup scorer Enner Valencia despite the three-goal forward being taken off on a stretcher late on against the Netherlands, and he failed to make any impact.
The four points they had accrued prior to the game meant Ecuador could play for a draw but they did not look like a side that had kept seven successive clean sheets earlier in 2022 and Senegal took full advantage.
-- Courtesy of BBC Sport