Third seed Federer, seven-times champion in Dubai, surged 5-1 ahead in the deciding tiebreaker but qualifier Donskoy reeled off six points in a row to secure a remarkable victory.
"Maybe I wasn't really committed enough, I think," the 35-year-old Federer said.
"Commitment in tennis is a big thing. Today I wasn't, really. That sort of is a feeling you get and it trickles in an entire game.
"Legs also felt slower out here tonight. I felt tired all day. I tried to get myself in shape, and, you know... It's just a tough loss tonight. So many chances. It was crazy. There's no excuses there."
Federer, who skipped last year's tournament because of a knee surgery which sidelined him for the back end of the season, refused to be downbeat over his first loss of the year.
"I just think it's still the beginning of the comeback," said Federer, who is scheduled to play at Indian Wells next week.
"I got to take the positives out of playing again in a tournament where I feel I'm quite healthy. I'm happy I got over the (groin) injury I sustained at the Australian Open."
Donskoy will next face French seventh seed Lucas Pouille, who beat qualifier Marius Copil 6-1 6-4, in the quarter-finals.
Top seed Andy Murray, who is playing in his first tournament since a fourth round defeat at the Australian Open, beat Guillermo Garcia-Lopez 6-2 6-0 to reach the quarter-finals, where he will face Germany's Philipp Kohlschreiber.
(Writing by Ed Osmond and Shravanth Vijayakumar; Editing by Alison Williams and Nick Mulvenney)
Share
