The Serb led by a break of serve in the final set at 2-1 but Wawrinka hit back to win 2-6 6-4 6-2 3-6 9-7, revenge for his defeat by Djokovic in another epic battle at the same stage last year.
The four-time champion, and winner in each of the past three years, missed a simple volley on match point to hand Wawrinka his semi-final spot and had no complaints about the result.
"Obviously I'm disappointed but tomorrow is a new day," Djokovic told reporters. "I have to accept the fact that you can't win all the matches that you play.
"One thing I can be proud of is that I gave my best (but) it wasn't enough. I know that I fought all the way through and laid my heart out there. It's a battle. One of us has to lose. He was a better player. He stepped in and he won the match."
Djokovic was bidding to become the first man in the open era to win the title four times in a row.
Having won the first set, Djokovic was out-hit by eighth seed Wawrinka, who fired a string of brilliant backhands for winners.
The Swiss levelled the match and then rode his momentum to go ahead only for Djokovic to hit back and force a decider.
When he broke for 2-1 in the final set, it looked as if he would pull off another dramatic escape but a loose game put things back on serve and then at 8-7, two errors from the Serb gave Wawrinka arguably the biggest win of his career.
"He served extremely well from the beginning to the end," Djokovic said.
"Every time he was in trouble, he was coming up with big serves.
"He took his opportunities. He deserved this win today. I congratulate him absolutely. There is nothing I can say."
Serving at 30-30 in what was the last game of the match, Djokovic put a forehand wide off a mis-hit Wawrinka return and then sent an easy volley long to see his winning streak come to an end.
"He had been chipping the return for the whole match, basically," Djokovic said of his choice to serve and volley on match point. "And it was actually a good decision. I had a good serve and volley and good volley, but didn't put it away."
Djokovic would not be drawn on whether Wawrinka, who plays Tomas Berdych in the semi-finals, could go on to win the title but said his form was no surprise.
"He's already feeling much more confident in the last year, year and a half," he said. "With his performances on the big tournaments, you can say that he deserves to be where he is.
"He deserves to win this match tonight because he's a great player and he's mentally matured and that's it."
- Sports & Recreation