The world number one and top seed had to break the Ivanovic serve three times to finally shake off the fifth-seeded Serbian to post a 2-6 6-3 7-5 victory in just under two hours.
The American top seed was jumped early by Ivanovic, who opened up a 4-1 double-break lead in the first set before serving it out.
But if the two-time champion was concerned, she did not show it as she broke immediately to start the second set and it was the only break as Williams levelled the match.
Williams again broke Ivanovic's serve for a 2-0 lead in the deciding set, however, Ivanovic broke back in the sixth game as the 17-time major winner failed to hold onto her advantage.
The local favourite broke again in the ninth game but could not serve it out - getting into a 0-40 hold, which Ivanovic eventually broke from at the third time of asking.
But Ivanovic could not get her nose in front, getting broken again in the 11th game, before Williams finally advanced.
Germany's Andrea Petkovic denied the Stanford crowd an all-Williams final, as she beat wildcard Venus Williams 6-1 3-6 7-5.
The eighth seed led by a set and a break but Williams broke the Petkovic serve three times in succession to send the match to a decider.
Similarly to the Williams-Ivanovic battle, Petkovic broke to go ahead on two occasions, only to be pegged back by a persistent opponent.
However, Petkovic held to love in the 11th game, before finally breaking Williams' serve to reach the last four of the WTA Premier event.
American Varvara Lepchenko coasted into the last four, thrashing compatriot and qualifier Sachia Vickery 6-1 6-0 - losing just seven points in the second set.
Lepchenko's opponent in the last four will be third seed Angelique Kerber, after the German comfortably dealt with Spain's Garbine Muguruza 6-2 6-1.


Ukraine launches fresh drone attack on St. Petersburg region on final day of ‘Ru...
US Ebola facility in Kenya fuels anger in a country with no cases
Ghana considering legal action against South Africa over xenophobic attacks — Ab...
There's no acrimony between Agric and Finance Ministers — Dafeamekpor
Finance and Agric Ministries clash could create COVID-like effect — Bryan Acheam...
Allow people to do their things in their rooms — Senyo Hosi on anti-LGBTQ bill
Disregard news of ministerial reshuffle — NDC urges Ghanaians
Awutu Senya East NDC Branch elections face uncertainty amid register controversy
Flooding is now a festival in Ghana, we have it every year – Kamal-Deen Abdulai
Mother, son arrested over alleged murder of husband at Nsawam-Adoagyiri
