The big-serving Croat coped well with the swirling winds as he completed a 6-7 7-6 6-4 win over Djokovic in Doha.
Karlovic, who had beaten the Serb when they last met in 2008, maintained a 73 percent first-serve percentage and sealed victory with two aces and two service winners in the final game.
In difficult conditions, Djokovic grew increasingly frustrated with his inability to claim a single break point opportunity.
Karlovic took full advantage of the deciding moment in the third set, snatching his second break point with a forehand pass to secure the seventh game.
“In these particular matches, one ball can decide a winner, and that was the case,” Djokovic said.
“I just played a little bit too defensive in that game. I just, instead of kind of going through the ball, just sent the ball back.”
Reflecting on the blustery weather, the 27-year-old said: “He served very well, but you could expect that.
???I was coming into the match knowing that I will have very, very few chances. But I was hoping that these conditions and the wind will kind of give me some second-serve opportunities.”
Karlovic added 21 aces to his resume for a career total of 9,062 and was fully aware of Djokovic???s growing irritation.
“I looked at him when he threw the racket and when he smashed the ball, so I knew that he was a little bit frustrated,” said Karlovic. “So I was just trying to stay calm.”
Third seed Tomas Berdych also booked his place in the semi-finals after a 6-2 6-1 win over sixth seed Richard Gasquet.