Boussefi struck in the fifth and 84th minutes to give Libya victory at Estadio de Bata, but Zambia's 1-0 win over co-host Equatorial Guinea in Group A's other game in Malabo - which was played at the same time - saw the Zambians progress.
Boussefi's early goal raised hopes of an unlikely quarterfinal place for the North Africans, who needed a win combined with a defeat for Zambia to have any chance.
Deme Ndiaye equalized in the 11th for Senegal, which was playing for pride, in a frantic start in Bata.
Boussefi claimed a late winner but Zambia progressed as group winner ahead of Equatorial Guinea, which had already qualified.
The Libyans still get to go home with a win, while Senegal slumped to a third straight loss at the tournament and a humiliating end to its Cup of Nations after being tipped as a possible contender.
The Senegalese lost all three of their games by the same scoreline, 2-1.