Osaka was a set and 4-1 down to the tricky Hsieh Su-wei before winning 11 of the last 12 games in a 5-7 6-4 6-1 victory.
Svitolina, who was again watched by boyfriend Gael Monfils, was arguably even closer to the exit door and struggling with a shoulder issue against Zhang Shuai.
The sixth seed trailed 3-0 in the third set before coming back to lead 5-3, failing to serve out the match and then eventually winning 4-6 6-4 7-5 in almost three hours.
Asked what her mindset had been in her on-court interview, Svitolina said: “I’m going to die or win.”
She added later: “This situation when I’m almost about to die, I think, ‘OK, there is an opponent across the net, and also struggling in the same situation, also running the same amount of hours on the court’. So I try to think that way and I’m not alone here in hell.”
Zhang had plenty of opportunities to really put the hammer down but could not quite do it and Svitolina went over to her Chinese opponent after the match to offer some consoling words.
“She’s a very nice person,” said Svitolina, who next faces 17th seed Madison Keys after her victory over last year’s semi-finalist Elise Mertens.
“It’s not only about tennis here. I think it’s very important to be a person and to be open. That’s what I am. It’s not like a big deal for me but, when someone is hurting, it’s normal to help.”
Osaka next faces 13th seed Anastasija Sevastova, who she beat in three sets at the warm-up tournament in Brisbane.
The US Open champion was proud of her response in adversity against Hsieh, saying: “Of course I’m happy with how I fought.
“For me, that’s one of the biggest things I always thought I could improve, because it sort of seems like before I would accept defeat in a way.”
Williams has been in devastating form and she made short work of 18-year-old Dayana Yastremska, winning 6-2 6-1.
The title favourite has dropped just nine games on her way to the fourth round and spent only three hours and six minutes on court in total.
Yastremska grew up idolising Williams, and the American gave her young opponent a hug at the net, telling her: “You did amazing, don’t cry.”
"Don't cry. You did amazing. Don't cry."— SportsCenter (@SportsCenter) January 19, 2019
Serena gave uplifting words to 18-year-old Dayana Yastremska after their match. pic.twitter.com/qHGmlBCSBd
Williams added later: “As she was walking towards the net, I could tell she was quite upset. I kind of liked that. It shows she wasn’t just there to play a good match, she was there to win.
“She wanted to win. That really broke my heart. I think she’s a good talent. It’s good to see that attitude.”
Williams also talked to Yastremska in the locker room after the match about a time violation the Ukrainian teenager received in the second set that the American felt was unfair.
“I didn’t think she deserved the time violation,” said Williams. “I thought that the umpire has to wait until the crowd stops clapping before announcing the score.
“I felt just to keep the match going he was announcing it really fast, which is fine, which is normal, but maybe she wasn’t used to that.
“I told her to definitely look into it so she knows going into the future what to expect. I think it’s important for young players to know the rules so they can always be educated for that. I told her I would look into it as well.”
Know more about Sport360 Application