A titanic struggle between the world's top two players saw Djokovic -- who looked out on his feet in the second set -- save a match point before coming through on his own fifth match point for a 5-7, 7-6 (9/7), 7-6 (7/4) triumph.
"It's crazy, I don't know what I can say," said 23-time Grand Slam champion Djokovic, who was seen by the doctors early in the second set for heat illness in a battle that lasted three hours and 44 minutes.
"It's tough to describe. It was the toughest I've ever played in my life.
"From start to finish we both went through highs, lows, incredible points, bad games, heatstroke, comebacks.
"Overall this was the toughest and most exciting match I've ever been a part of.
"It's matches like these that I continue to work for."
It was another epic chapter to the budding rivalry between 20-year-old top-ranked Alcaraz and the 36-year-old Serb star, who avenged his loss to the Spaniard in a five-set Wimbledon final last month.
The two -- who have traded the number one ranking six times this year -- are now level on two wins apiece in their head-to-head rivalry.
"I feel proud of myself, honestly. I don't know why I was crying because I fight until the last ball," Alcaraz said.
"I almost beat one of the greatest of all time in our sport. I left the court really happy with what I did."
The 20-year-old unleashed everything he had at Djokovic and found it wasn't enough.
"It was really, really difficult playing. Novak returns five, six, seven balls on every point," Alcaraz said.
"So fighting and running from one corner to the other one on every point is really tough to deal with for almost the whole match.
"I left everything on court. I'm working very well. But today, it was tough to deal with everything that Novak had."
Djokovic, who earned a record-extending 39th victory at the elite Masters 1000 level, secured the first break of the opening set at love for a 4-2 lead.
Alcaraz broke back and broke again for a 6-5 lead then held to take the set before Djokovic left the court for a seven-minute change of clothes.
Djokovic, clearly affected by the hot, muggy conditions, was visited by the trainer and doctor in the second set.
He was broken to trail 2-1, Alcaraz grabbing a 4-2 edge with a drop shot that Djokovic couldn't touch.
But the 23-time Grand Slam winner broke Alcaraz to pull level 4-4 on the way to a tie-breaker.
Djokovic saved a match point at 5-6 and forced a third set when Alcaraz dumped a shot into the net on Djokovic's second set point.
- Never in doubt -
Djokovic headed off to the locker room for another clothing change while Alcaraz pounded his right hand on his bench in frustration as he sat down.
The Spaniard -- who then needed to have a finger taped up -- was broken in a nine-minute seventh game that featured five break points.
The back-and-forth battle continued, Djokovic unable to convert serving for the match at 5-4 but putting it away two games later after the longest best-of-three set final in ATP Tour history.
A weary Djokovic dropped to the court in relief, then bounced up and ripped his shirt down the middle as he let out a roar of triumph or agony -- or perhaps a bit of both.
"I was never in doubt that I could deliver the match when it mattered the most," he said, adding that the rivalry with Alcaraz "is just getting better and better."
"Carlos is an amazing player, I have tons of respect for him," Djokovic said. "He is so poised at such a young age."
Alcaraz will remain number one in the world and will be the top seed while defending his title at the US Open, which starts on August 28.
Djokovic, who declined to be vaccinated against Covid-19, was playing his first US tournament in two years.
(For more sports news and updates, follow Ahram Online Sports on Twitter at @AO_Sports and on Facebook at AhramOnlineSports.)