Ostapenko came from a break down in the deciding set, winning the last five games to beat Muguruza for the first time and a world No. 1 for the first time.
“I just beat No. 1 and it’s amazing,” Ostapenko said.
No. 4-ranked Karolina Pliskova also lost from a set up, falling to Ashleigh Barty of Australia who beat a top-five player for the first time 4-6, 7-6 (3), 7-6 (2).
Barty will meet Ostapenko, the only seed to reach the semifinals. The other semi features Caroline Garcia of France and qualifier Maria Sakkari of Greece.
Muguruza made a flying start, thanks in part to Ostapenko’s 15 unforced errors. But in the second set, the Latvian broke Muguruza four times to lead 5-3. Muguruza held serve but Ostapenko won the set with a winner down the line.
Muguruza made the early break in the decider but the Spaniard was outgunned from the baseline by Ostapenko, who hit a total of 29 winners to 11 by Muguruza.
Little separated Pliskova and Barty. Pliskova made the one decisive break in the first set, and Barty won the last four points of the second-set tiebreaker. Pliskova finally lost her service game to open the third set, and began a series of traded breaks.
Barty squandered three match points at 5-4 but led in the tiebreaker, which she clinched when Pliskova double-faulted after 2 1/2 hours.
Garcia beat Ekaterina Makarova of Russia 7-6 (3), 6-4. Sakkari defeated Alize Cornet of France 7-6 (2), 7-5 to become the first qualifier to make it to the semifinals at Wuhan.
“I still cannot believe I’m in the semis,” Sakkari said.