Medvedev dropped to second with a third-round loss to Gael Monfils at Indian Wells last week but would have taken back the top spot from Serbia's Novak Djokovic had he defeated Hurkacz, the defending Miami Open champion.
Instead, 10th-ranked Hurkacz advanced to the semi-finals by ousting the reigning US Open champion at Hard Rock Stadium and 20-time Grand Slam champion Djokovic stays number one.
Hurkacz, now 2-2 all-time against the Russian, faces Carlos Alcaraz for a place in Sunday's final after the 18-year-old Spanish sensation produced a scintillating display to beat 48th-ranked Serbian Miomir Kecmanovic in three sets in one of the best matches of the tournament.
Medvedev said he found it hard to breathe at times and was cramping so badly in the locker room he was like "a fish on a sofa."
"All match, I wasn't feeling my best," Medvedev said. "After the tough points I was struggling to get my breath. I wasn’t recovering fast enough. You just have to fight but in the second set I felt strange.
"I don't often feel like this but it happens sometimes when it's hot. Maybe it was the heat but I was feeling dizzy and tired and there was one game where I couldn't serve anymore. In the locker room I was cramping."
Medvedev called for medical trainers in the second set.
"The physio gave me something," he said. "You never know. You're hoping it will be like a magic thing but it doesn't always work like this."'Cramp, cramp, cramp'
Hurkacz played well, taking full advantage of Medvedev's struggles, which lasted well after he walked off the court.
"Normally I would just sit for a bit in the locker room but then I started cramping," he said. "I had a shower and felt a bit better. That was good advice because I was sitting down, was really tired and every muscle started going cramp, cramp, cramp. I was like a fish on the sofa.
"It's nothing serious. I'll wake up and probably be fine, but that's no good if I'm out of the tournament."
Medvedev was having trouble with his service games throughout -- his first serve percentage was just 43% as he attempted to stay in the first set at 2-5 down, but there was hope when he broke back and managed to draw level at 5-5.
But he was unable to stem the tide as Hurkacz, whose serve was key, powered into the last four.
"I knew Hubert could play great tennis and it was more important to win the game than become number one," Medvedev said. "That would have been a bonus."
Hurkacz said his return of serve was crucial.
"I was able to make a lot of returns and get some free points on my serve, because having rallies with Daniil is fun, but they get long," Hurkacz said. "It's good I was able to get some free points."
If Hurkacz wins on Friday, he will become the first player to reach the Miami Open men's singles and doubles finals in the same year. He teamed up with John Isner after his match against Medvedev and delivered another solid performance to help topple Australian Open champions Nick Kyrgios and Thanasi Kokkinakis in the last four of the men's doubles.