Oumar Diakite scored in added time after the match was sent to extra time, with a 120+3 minute winner for the host nation.
Moments after finding the back of the net from outside the box following a corner, Diakite was sent off for his wild celebrations.
Hamari Traore of Mali followed him seconds later after surrounding the referee before officials were escorted off for their safety.
As the final whistle erupted, Ivory Coast continued their wild celebrations as they booked a spot in the AFCON semi-finals.
Fans were quick to react to the sensational win, especially given Ivory Coast's rocky journey at AFCON.
Ine user posted as cited by Sports Central: 'My goodness Ivory Coast. What an extraordinary story: Survived group stage after finishing last. Their manager resigned. Survived Senegal with the last kick of the game. They have survived Mali with 10 men. Ivory Coast have more lives than a cat.
Gary Lineker added: 'Wow! Ivory Coast who’ve played most of the game with 10 men have won it at the very end of extra time. What a moment for the host nation.'
Another joined: 'Never has a team looked simultaneously so out of a tournament and so certain to win it as Ivory Coast. Incredible commitment to teetering on the brink during this AFCON.
Another penned: 'Have a team ever won a major international tournament after sacking their manager mid tournament? Ivory Coast are crazy.
The host nation did not enjoy an ideal start to the tournament, after losing two of their three group games, including a 4-0 loss to Equatorial Guinea.
Things continued to heat up for the hosts as they went on sack coach Jean-Louis Gasset but then miraculously scraped into the knockout stages by the barest of margins.
Gasset was duly replaced by a total novice in Emerse Faé ahead of a daunting last-16 match against the reigning champions Senegal.
After defeating favourites Senegal 5-4 on penalties, the side faced Mali in the quarter-finals having only won once in 90 minutes.
Ivory Coast will face Democratic Republic of Congo in the semi-finals on Wednesday..