The 36-year-old Serbian, who is back up to world number one, beat third seed Medvedev 6-3 7-6 (5) 6-3 for a fourth Flushing Meadows crown.
The match hinged on a marathon second set lasting 104 minutes, which was longer than both players’ entire first-round matches.
Djokovic won it after a tie-break to move 2-0 up and finally break Medvedev’s spirit, going on to gain a measure of revenge after the Russian denied him the calendar grand slam in the final here two years ago.
The win also moved him level with Margaret Court’s record of major titles, although really that is a statistical irrelevance given the obvious difference in the level and depth of competition between now and the 1960s.
Of more importance to Djokovic is his record against his peers; he is now two clear of Rafael Nadal’s 22 grand slam crowns and four ahead of Roger Federer, who declared on 20 last year.
Having already won in Australia and Paris, Djokovic has picked up three major titles in a year for the fourth time in his career. Only the five-set defeat by Carlos Alcaraz in the Wimbledon final blemished his 2023 record.
Now he has surpassed Ken Rosewall, who was 35 when he won in 1970, and who did not have to contend with any sets lasting almost an hour and a quarter.
Djokovic, who missed last year’s championships due to his vaccine status, wore a tracksuit top adorned with the number 24 – which presumably would not have seen the light of day had he lost – for the trophy presentation.
He said: “I don’t know where to start, it obviously means the world to me. I’m really living my childhood dream to compete at the highest level in a sport that has given me and my family so much.
“I never imagined I would be standing here talking about 24 slams. But the last couple of years I felt I had a chance, a shot at history, so why not grab it?”
A Medvedev double-fault and a blistering backhand winner down the line gave Djokovic the early break point which he converted to love to subsequently take the first set in a relatively speedy 48 minutes.
But Medvedev, returning from about a quarter-of-a-mile behind the baseline, made Djokovic toil in the second set and it began to show with the favourite showing signs of fatigue.
After an hour and three quarters he produced his first break point of the match but Djokovic, with an obvious change of game plan in a bid to shorten the points, expertly snuffed it out with a big serve and an immaculate volley.
Medvedev had set point on the Djokovic serve but another volley at the net dealt with that, and when tie-break slipped away from the 27-year-old, the match soon followed.
Medvedev said: “First of all I want to ask Novak what are you still doing here? I mean come on.
“I don’t know when you are planning to slow down a little bit. I feel like I have a good career, I have 20 titles, but you have 24 grand slams. Wow!”