Reigning US and Australian Open champion Osaka broke at love in the final game to defeat Polish teen Iga Swiatek 7-6 (7/4), 6-4 after one hour and 51 minutes.
World number 10 Williams was broken twice and dropped the first three games in 10 minutes then battled back to defeat Russia's 48th-ranked Ekaterina Alexandrova 7-5, 6-4 in 91 minutes.
That set the stage for Williams, a 37-year-old American who will try for a record-tying 24th Grand Slam singles title at the upcoming US Open, to face Osaka on Friday.
"I've been actually looking forward to playing her for a while," Williams said. "She has had a great year early in the season and she's still doing pretty good."
It will be their first match since the controversial finish to their Grand Slam showdown last year in New York.
The 21-year-old Japanese star defeated her childhood idol 6-2, 6-4 in last year's US Open final, a match marred by an on-court dispute between Williams and the umpire that led to a game penalty against Williams.
Osaka was booed by some fans during the awards ceremony and later dubbed what should have been her moment of glory "a little bittersweet."
"I guess I'll treat it like a regular quarterfinal, but I haven't been in a quarterfinal in a while," Osaka said after winning Thursday.
"I'm just really excited. I grew up watching her, so whenever I get the opportunity to play her, it's something I feel is a once-in-a-lifetime opportunity.
"And it feels more like I'm showcasing my skills to her, like, 'Look what I can do?' You know what I mean?
"So I go into the matches with that mentality. And just super grateful to get the chance to play her."
Alexandrova broke Williams -- the 2001, 2011 and 2013 Canadian champion -- in the first and third games for a 3-0 edge only to have Williams roll through the next four games.
They held from there until the final game of the first set, when the Russian's eighth double fault handed Williams the set after 46 minutes.
"(Alexandrova) hit really, really hard and she was hitting a lot of winners, so I was just happy I was able to just fight through that," Williams said.
Alexandrova broke Williams again to open the second set, but the US star pulled level in the sixth game and broke again in the 12th to advance after 91 minutes.
"I'm feeling good," Williams said. "Just hopefully just being able to stay in the rhythm and playing this week and next week would be good."
Williams said she is struggling with the transition from clay to grass to hardcourts more than usual this year.
"It takes a while to get back into the rhythm," she said. "Usually I don't feel that huge a difference, but for whatever reason I do this year."
- Pliskova chases No. 1 -
Czech third seed Karolina Pliskova kept the pressure on Osaka in the battle to take the world number one ranking by also reaching the quarter-finals.
Pliskova eliminated Estonia's Anett Kontaveit 6-3, 7-5 to set up a last-eight clash with rising Canadian star Bianca Andreescu, who outlasted fifth-seeded Dutchwoman Kiki Bertens 6-1, 6-7 (7/9), 6-4.
Pliskova, 27, must reach the final to have any chance of taking the top spot next week for the first time since 2017. Otherwise, Osaka will claim the number one berth.
French Open champion Ashleigh Barty's stint as the world's top-ranked player was assured of ending after she was knocked out on Tuesday.
Defending champion and fourth seed Simona Halep of Romania, coming off a Wimbledon title last month, beat Russia's Svetlana Kuznetsova 6-2, 6-1 to book a quarter-final against Czech qualifier Marie Bouzkova, who ousted Latvia's Jelena Ostapenko 6-2, 6-2.