Medvedev looked to be cruising in losing just one game in a 28-minute opening set, but the third seed was left reeling after Bautista Agut dug deep to triumph 1-6 6-4 6-3 and set up a semi-final meeting with Novak Djokovic.
Bautista Agut, seeded eighth, saved 15 of 20 break points to frustrate Medvedev as he prevailed in two hours and 13 minutes.
"After the first set, I was thinking a lot of bad things," Bautista Agut said on the ATP Tour's official website. "It was a very good comeback."
Bautista Agut has won two of his most recent three matches against Djokovic, the world number one, and although the Spaniard is undaunted, he knows he faces a stiff test against the Serbian.
"He is a great player, very solid, very aggressive and he has a lot of weapons," Bautista Agut said.
"Against him, I will try to play my best game to beat him. If I can play a good level it is going to be a good match."
Djokovic was rarely stretched as he extended his unbeaten run to 24 matches, which includes a 21-0 record this year, with a 6-3 6-1 victory over Germany's Jan-Lennard Struff.
"Ever since I made that break at the beginning of the first set, I never looked back," Djokovic said. "I really played very aggressive whenever I had the chance and I was going for my shots."
Fourth seed Stefanos Tsitsipas advanced to the last four after America's Reilly Opelka retired hurt in the first set. The Greek was 6-5 up before Opelka withdrew because of a right knee injury.
Tsitsipas will play Andy Murray's conqueror Milon Raonic after the Canadian dropped his first set of the tournament in a 4-6 7-6 (2) 7-5 defeat of unseeded Serbian Filip Krajinovic.