Ryan Mendes converted a late penalty as Cape Verde, with Roberto 'Pico' Lopes again lining out in defence, beat Mauritania 1-0 in Abidjan to seal their place in the quarter-finals of the Africa Cup of Nations.
But the holders Senegal are out after losing on penalties to Ivory Coast following a 1-1 draw.
Skipper Mendes struck the decisive spot kick for Cape Verde in the 88th minute and the Blue Sharks, with Shamrock Rovers' Lopes in their ranks, will now face either Morocco or South Africa in the quarter-finals.
Cape Verde, one of the surprise teams of the tournament after finishing unbeaten at the top of Group B ahead of Egypt and Ghana, were second best for most of the first half, but finished strongly to secure their passage.
Mauritania had reached the tournament's knockout stages for the first time by defeating two-time winners Algeria 1-0 in their final group game to progress as one of the best third-placed teams.
The first-half action was end-to-end, but clear-cut chances were at a premium, while Mauritania were dealt a blow in the 35th minute when Omare Gassama was carried off on a stretcher and replaced by Guessouma Fofana.
Mendes' early effort for Cape Verde was deflected into the side-netting and Mauritania captain Mouhsine Bodda curled a 15th-minute free-kick just wide.
Mauritania made all the early running in the second period and Souleymane Anne missed the game's best chance from open play when firing wide after Sidi Amar's surging run into the penalty area just before the hour-mark.
Cape Verde came on strongly in the closing stages with both Garry Rodrigues' drive and Mendes' header forcing Mauritania goalkeeper Babacar Niasse into excellent saves.
The game's decisive moment came in the 87th minute when Yassin El Welly's misplaced headed back-pass was pounced on by substitute Gilson Benchimol, who was brought down by Niasse for a clear penalty.
Mendes held his nerve, drilling his spot-kick down the middle and the Blue Sharks saw out 10 minutes of added time to seal their place in the last eight.

Moussa Niakhate missed his penalty in the shoot-out as holders Senegal tumbled out of tournament after a drama-filled 5-4 loss to hosts Ivory Coast following a 1-1 draw at the Charles Konan Banny Stadium.
Senegal were quick out the blocks and took the lead inside four minutes as Sadio Mane's cross from the left was chested down by Habib Diallo, whose thunderous shot from 10-yards settled in the top corner of the net.
Mane was fortunate not to get a red card shortly after that following a poor challenge, but Senegal could not add to their lead and paid the price when the Ivorians were awarded a clear penalty and equalised through Franck Kessie four minutes from the end of the 90 minutes.
Ivory Coast will face the winner of Tuesday's last-16 tie between Mali and Burkina Faso in the quarter-finals on Saturday.