Djokovic, who has won the last three championships in Dubai, was a huge favourite to advance to a quarter-final against compatriot Janko Tipsarevic, who had earlier beaten Flavio Cipolla 6-7 6-1 6-1, but was some way from his best against his Ukrainian opponent.
The world number 74 asked plenty of questions of Djokovic, but was edged out on the crucial points and beaten after an 89-minute contest.
"I was expecting a lot of serve and volley attacks, especially after first serve," said Djokovic. "He was using it really well, making my return games very difficult."
"[Janko's] very solid from the baseline... when he has time and he steps into the court, he's very dangerous. I need to try to be aggressive. I need to try to stay close to the line. That's all. He doesn't have many weaknesses in his game."
Stakhovksy had not overcome a top 10-ranked opponent in his career to date, but demonstrated his full away of strokes and played with style behind a serve-and-volley game.
Both men managed to earn a solitary break point in the first set, and there was little to separate the two going into the tie-break.
Stakhovsky twice had the advantage of a mini-break and on serve at 4-3 up, only for Djokovic to pounce on two backhand errors and wrest the advantage.
Any thoughts that the Serbian had broken his opponent with that were soon dispelled as Stakhovsky took the first break of serve in the match early in the second set to forge a 3-1 lead.
Djokovic clicked into gear, however, levelling at 3-3 after ripping a backhand past the Ukrainian at the net. The defending champion continued to apply the pressure, and it told on the next service game, with Stakhovsky double-faulting on break point.
That left the Serbian to serve for the match, and he did so with conviction, finishing off with an ace down the middle.
Seventh seed Tipsarevic had earlier been shaded in a tight first set by Cipolla, who had come into the match on the back of an impressive victory over Ivan Ljubicic.
But Tipsarevic conceded just two more games thereafter, setting up the Djokovic quarter-final clash with a victory after two hours and 15 minutes.