Libya exited the Africa Cup of Nations with a 2-1 consolation win over Senegal, who finished without a point.
Ihab Albusaifi struck in each half for the Libyans, the second a wonderful volley and worthy match winner.
Deme Ndiaye scored for Senegal but it was of little consolation as the Senegalese go home after three losses.
Libya's win marked their first in the Nations Cup in 30 years, as they ended up third in Group A behind Zambia and Equatorial Guinea, with Senegal bottom.
The Mediterranean Knights needed a win at the start of the game to have any hope of staying in the tournament, with Zambia and co-hosts Equatorial Guinea kicking off in Malabo at the same time.
Pre-tournament favourites Senegal, meanwhile, were looking to salvage some pride after losing their opening two games.
And the Libyans got off to the perfect start with Albusaifi prodding home with the outside of his boot, underneath Senegal goalkeeper Khadim Ndiaye, after just five minutes.
Senegal, who looked sharper in their final group game, hit back just 11 minutes later.
Deme Ndiaye headed in captain Mamadou Niang's corner off the inside of the woodwork, after rising highest at the near post.
The Senegalese forced another series of corners, looking to edge ahead through a further set-piece, but could not make the pressure count.
Meanwhile, Libya's passing was found wanting as they tried to press forward but overcooked several balls aimed towards their front men.
The match also became very stop-start, with niggly fouls from both sides, as the two teams sought to edge ahead.
Moussa Sow came on for Senegalese captain Mamadou Niang, while Papiss Demba Cisse replaced Newcastle team-mate Demba Ba in attack.
But neither substitute could convert chances, with Cisse trying to chip Aboud from outside the box but floating it over, and Sow missing a good chance at the near post.
The Libyan attack finally got back into their stride deep in the second half, with Ahmed Sa'ad Osman threatening and trying to thread balls through, mainly to Ahmed Zuway.
And they eventually got their reward when Zuway laid off the ball wonderfully to Albusaifi who rifled into the back of the net with his right foot from eight yards out.
Ihab wheeled away in delight, as Libya held on for their first Nations Cup victory since hosting the tournament in 1982, and their first on foreign soil.
It was not enough for them to go through to the last eight, however, after Zambia's 1-0 win over Equatorial Guinea in Malabo put the Chipolopolo through as Group A winners, with the co-hosts finishing second.