complained then argued with the chair umpire before Medvedev held serve to level the set at five games all.
The set remained on serve following two additional holds of service games to reach a tiebreaker.
Djokovic led 5-3 in the tiebreaker following several successful dropshot plays.
Medvedev struck two dropshots of his own to level the tiebreaker at 5 points all before netting a crosscourt forehand volley to trail 5-6.
Djokovic netted a down the line backhand passing shot to reach six points all before striking an overhead winner to lead 7-6.
On Djokovic's second set point, Medvedev struck a dropshot which Djokovic returned.
The 26 year old Medvedev then struck a down the line passing shot long to drop the set before he retired from the match injured with a pulled abductor muscle in his leg after one hour and 46 minutes of play.
Tomorrow in the Astana final, the 35 year old Djokovic faces the 24 year old third seeded Stefanos Tsitsipas of Greece.
Djokovic has won Wimbledon the last four years it was played and leads Tsitsipas head to head 7-2.
Djokovic defeated Tsitsipas in their last six matches with the most recent win coming earlier this year in the spring in the Rome final on clay 6-0, 7-6 (7-5).