Medvedev, who now leads the ATP with 30 hardcourt wins this season, will play for the title on Sunday against Belgium's David Goffin, who defeated France's Richard Gasquet 6-3, 6-4.
Both defending champion Djokovic and Medvedev had reached the semi-finals without dropping a set.
But it's Medvedev who will be play his second Masters final in eight days, after losing to Rafael Nadal in the Montreal title match on Sunday.
The week previously, the 23-year-old also played the Washington final, losing to Nick Kyrgios.
Djokovic appeared to have the contest under control, but had no answer when Medvedev stepped up the pressure in the second set.
"I don't know how I turned it around, I was so tired after the first set and I thought I might not be able to keep up the intensity," Medvedev said. "But I had a momentum chance in the second set and the crowd gave me energy."
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ