Host nation Qatar were eliminated from the World Cup on Friday with one Group A game still to play after Ecuador held the Netherlands to a 1-1 draw.
Qatar had earlier gone down to a second successive defeat in the tournament, losing 3-1 to Senegal meaning they needed Ecuador to beat the Dutch in order to stay in contention.
Goals either side of half-time from Boulaye Dia and Famara Diedhiou gave Senegal the lead before Qatar substitute Mohammed Muntari replied in the 78th minute to set up a dramatic finale.
Senegal substitute Bamba Dieng scored six minutes later to put the result beyond doubt and lift the African champions, who opened with a 2-0 loss to the Netherlands, right back into contention in Group A.
The defeat left bottom side Qatar sweating on results elsewhere if they are to avoid following South Africa in 2010 as only the second World Cup hosts to bow out after the first round.
Their elimination would be confirmed if Ecuador fail to beat the Netherlands later in the day, and would make Qatar the first World Cup hosts to go out after two games.
Qatar had made a nervy start to the tournament in a 2-0 defeat to Ecuador and they again looked tentative against Senegal.
Qatar's fans cheer for their team as they attend the World Cup Group A football match between Qatar and Senegal. AFP
Starting line-ups:
Qatar (5-3-2)
Meshaal Barsham; Pedro Miguel, Ismail Mohamad, Boualem Khoukhi, Abdelkarim Hassan, Homam Ahmed; Karim Boudiaf, Assim Madibo, Hassan Al Haydos (capt); Almoez Ali, Akram Afif
Coach: Felix Sanchez (ESP)
Senegal (4-3-3)
Edouard Mendy; Youssouf Sabaly, Kalidou Koulibaly (capt), Ismail Jakobs, Abdou Diallo; Idrissa Gana Gueye, Nampalys Mendy, Krepin Diatta; Boulaye Dia, Ismaila Sarr, Famara Diedhiou
Coach: Aliou Cisse (SEN)
Referee: Antonio Mateu Lahoz (ESP)
Agence France-Presse