The Blue Sharks went into the last-16 clash as favourites, having gone unbeaten on their way to the knockout stages as they topped Group B ahead of Egypt and Ghana. Mauritania, meanwhile, had edged through after stunning Algeria in their final group-stage game, for what was their first ever win at the tournament.
It was a tight affair for much of this match, with Mauritania competing in their first AFCON knockout game, and for 87 minutes it looked as though extra-time would be required to split them.
Souleymane Anne wasted a huge second-half chance to put Mauritania ahead, slicing his shot wide when clean through in the area, and that miss felt increasingly costly as Cape Verde began to pile on the pressure.
A succession of corners were swung into the Mauritania box and Mendes had a header superbly saved, as the Lions of Chinguetti just about held firm and edged towards the end of normal time.
One mistake was all it took though, as Yassin El Welly tried to head the ball back to his goalkeeper and instead nodded it perfectly into the path of Gilson Benchimol. The Cape Verde forward went round Babacar Niasse and was brought down, the referee wasting no time in pointing to the spot.
Captain Mendes stepped up and lashed his penalty straight down the middle, before Cape Verde survived ten minutes of stoppage-time to set up a quarter-final against either Morocco or South Africa.