The Serbian 11th seed beat Sharapova, seeded eighth, for the first time in seven years with a blistering display of power to reach her sixth quarter final of 2014.
Ivanovic will face Carla Suarez Navarro in the semis after the Spaniard was granted a walkover against fourth-seeded Romanian Simona Halep, who pulled out with an abdominal strain.
The last time Ivanovic, 26, beat the Russian was in the semi-finals of the 2007 French Open. She went on to lose the final to Justine Henin.
'A part of my life left with Federer' – Nadal recalls emotional goodbye to tennis legend

Maria Sharapova at the 2014 Italian Open in Rome (Reuters)

Image credit: Eurosport

China's second seed Li Na snapped a career-long jinx against Australian Samantha Stosur, winning 6-3 6-1 having lost their previous six meetings, and will meets Italy's Sara Errani in the last eight.
World number one Serena Williams brushed aside fellow American Varvara Lepchenko 6-1 6-2 to draw level with sister Venus for the most career wins among active players. Serena's 652nd win set up a quarter-final against China's Zhang Shuai.
Italian Open third round results
1-Serena Williams (US) beat Varvara Lepchenko (US) 6-1 6-2
6-Jelena Jankovic (Serbia) beat 12-Flavia Pennetta (Italy) 6-2 6-3
Zhang Shuai (China) beat Christina Mchale (US) 6-2 4-6 6-2
11-Ana Ivanovic (Serbia) beat 8-Maria Sharapova (Russia) 6-1 6-4
3-Agnieszka Radwanska (Poland) beat Francesca Schiavone (Italy) 6-4 6-1
10-Sara Errani (Italy) beat Petra Cetkovska (Czech Republic) 6-4 7-6(3)
2-Li Na (China) beat Samantha Stosur (Australia) 6-3 6-1
13-Carla Suarez Navarro (Spain) beat 4-Simona Halep (Romania) walkover
Davis Cup
Australia edge past Croatia to reach Davis Cup final
Medvedev, Tsitsipas have had their confidence hurt by the Big Three - Mouratoglou