Goffin denied Djokovic a possible 50th career match against defending champion Rafael Nadal, who was playing the last remaining quarterfinal against unseeded Diego Schwartzman.
"It's the best win of my career," the 10th-seeded Goffin said.
Goffin had lost all previous five matches to Djokovic and looked to heading for another when the 12-time Grand Slam winner led 4-2 in the decider.
But Goffin broke him in the eighth game and held firm on his own serve when taken to deuce in a tight 11th game.
The pressure was back on the second-ranked Djokovic to hold and force a tiebreak, but Goffin kept coming at him and Djokovic also had to cope with a time violation during that tense 12th game for taking too long to serve.
"That's fair from the chair umpire to tell me that I'm taking a little bit too much time. It was just in a very awkward moment to give me a warning," Djokovic said. "It's just that sometimes there should be maybe a little bit more tolerance and understanding for certain situations like that one, where it was very long point, at 6-5 in the third."
The early evening light on the court was still bright enough to affect both players, with Goffin saying it was "a nuisance" when he was serving at 5-5 and Djokovic complaining that it was "almost unplayable" in the nail-biting 12th game.
"(Like) someone putting a flashlight directly in your eyes," he said.
Djokovic saved the first match point with an ace; the second one on his second serve; the third with a stinging forehand winner and a fourth when Goffin chopped a backhand into the net.
But a sloppy unforced error on forehand gave Goffin another chance, and he took it with a deep forehand right on the line that Djokovic swiped back off balance into the net.
Goffin, who had taken just one set off Djokovic before Friday, grabbed his head with both hands.
Djokovic, the champion here in 2013 and 2015, hugged him at the net.
He had scraped this far, anyway. This match took 2 hours, 38 minutes, taking the Serbian's total time on court to 7h35 over his three matches. Djokovic was taken to three sets by 32nd-ranked Gilles Simon and 19th-ranked Pablo Carreno Busta and could well have lost both.
Goffin took the first set in little more than 30 minutes.
"I started slowly probably because I played two long matches. But I thought as the match progressed I was feeling OK," said Djokovic who recently returned from an elbow injury. "I was physically fine. We had a lot of exchanges, a lot of rallies. David was playing very quick."
Djokovic found his range in the second, pushing the Belgian further back. Goffin saved two sets points on his serve at 5-3 down, but Djokovic held easily on his next service game to level the match.
The momentum was with Djokovic, but the resilient Goffin had other ideas.
Cilic, the 2014 U.S. Open champion, seemed to be in command when he broke at the start of the third set. But the Spaniard rallied to set up a semi against Lucas Pouille of France, who beat Pablo Cuevas of Uruguay 6-0, 3-6, 7-5.
Pouille reached the quarterfinals at the U.S. Open and Wimbledon last year in his breakthrough season.
Cuevas was poor in the first set against Pouille, winning no points on his second serve and failing to save any break points. He started to find range with his one-handed backhand in the second set and leveled the set score when Pouille netted a return.
Pouille offered an explanation as to why he lost his way after a one-sided first set.
"I should have gone off the court as well when he went off for a toilet break," Pouille said. "I lost my momentum a bit."