Russian Kasatkina took advantage of a sub-par serving night from the more powerful Williams, forcing long rallies that ultimately wore the veteran down over the course of the nearly three hour contest on a chilly night in the California desert.
The win sets up a showdown against either world number one Simona Halep or fellow 20-year-old Naomi Osaka of Japan, who play later on Friday.
Kasatkina, who fought back after being two points away from losing in the third set, put her hands on her head in shock when Williams hit a backhand into the net on match point, handing the Russian the biggest win of her career.
"I'm a bit tired," Kasatkina said during an on-court interview after the match.
"One more to go."
The win extends the Cinderella run for the tournament's 20th seed, who defeated grand slam champions Sloane Stephens, Caroline Wozniacki and Angelique Kerber without dropping a set before going the distance to take down Williams.
Williams played an excellent all-around game, mixing bruising groundstrokes with frequent approaches to the net and moving well around the court.
But she was unable to pile up easy points on serve, winning barely half the points on her first serve while being broken seven times.
Kasatinka will now have Saturday to recover before facing either Halep, who holds a 3-1 lead in their previous four meetings, or Osaka, who she has never played before.