Edmund, who reached the final of this year's Australian Open, had never previously won a set against the 10th seed, who is still working his way back to top form after a long battle with injuries, but needed one hour and 42 minutes to defeat the Serb.
He had a chance to go up a break early in the third set but lost five straight points to allow Edmund to come back from 0-40.
The pair traded breaks to begin the match before a double fault by Djokovic, now ranked 12th in the world, handed Edmund the initiative.
"I was looking forward to having these kind of matches, looking to trying to win these kind of matches", Djokovic said. "I feel much better about everything that is happening on the court and around tennis, in general, with my body than maybe two months ago".
Later, France's Gael Monfils beat Georgian Nikoloz Basilashvili 6-2 3-6 6-3 to set up a second-round clash today with champion and tournament favourite, Rafael Nadal.
Serving to stay in the opening set, Djokovic played a terrible game and, with three set points, Edmund took the first when a driving return caught the line.
"There are obvious things that are not working well for me", Djokovic said.
The Brit made the most of a break point in the eighth game - his solitary opportunity of the final set - before emphatically serving for victory. Obviously, I've played this sport so many years and had a bunch of success.
Earlier, Simona Halep maintained her charge towards a third consecutive Madrid Open title as she eased past Kristyna Pliskova 6-1 6-4. And that's something also that makes me fortunate to play the sport.
"I haven't had an easy draw here, but I don't think anyone has".
"It'll be another tough match", Wozniacki said. The Dane could have ursurped Halep as world number one by winning the title this week but instead endured a shock 6-2 6-2 defeat to Kiki Bertens. The former world No.1 has not played a competitive match since Wimbledon last summer and aborted comeback attempts at the US Open and Australian Open in January after which he had surgery in Melbourne.
Unseeded Sharapova will next face last year's finalist Kristina Mladenovic, who edged China's Zhang Shuai 6-4 4-6 6-3.