Gabon suffered penalty shoot-out heartbreak as Mali prevented them from reaching a first African Nations Cup semi-final in Libreville.
Pierre-Emerick Aubameyang missed the only penalty of the shoot-out for the hosts and the Gabon striker broke down in tears after Mali's Barcelona playmaker Seydou Keita netted the winning spot-kick.
It was cruel on Gabon who had been on the verge of progressing thanks to Eric Mouloungui's 55th-minute opener only for Cheick Diabate to equalise with six minutes left in normal time.
Mali had Modibo Maiga sent off moments later but Gabon failed to make their one-man advantage count in extra-time before crashing out in the shoot-out.
Gabon had the best of a goalless first half with Aubameyang, who had scored in each of the group stage games, hitting a post from 12 yards after 29 minutes.
The hosts did deservedly go ahead on 55 minutes when Aubameyang cut a pass back for Mouloungui, who forced his shot in despite Keita's desperate effort to clear off the line.
That looked enough to secure the hosts an historic success until Maiga teed-up Diabate to score with six minutes remaining.
The match took another turn a minute later when Maiga was given his marching orders for a second caution.
Gabon failed to capitalise on his absence in extra-time and were lucky even to reach the shoot-out as Diabate missed a header from six yards after he was picked out by Adama Tamboura's free-kick.