Playing in his fifth final and desperate to avoid joining Fred Stolle as the only man ever to lose his first five, Murray looked firmly on course when he won both the opening two sets.
But Djokovic, who had not lost a grand slam match on hard courts for two years, fought back to level before Murray eventually came through 7-6 (12/10) 7-5 2-6 3-6 6-2 after four hours and 54 minutes.
There was a real desire within tennis for the 25-year-old to win a title, even from Djokovic, Roger Federer and Rafael Nadal, the men who have so often denied him.
Djokovic said: "Any loss is a bad loss. There is no question about it. I'm disappointed to lose the match but, in the back of my mind, I knew that I gave it all. I really, really tried to fight my way back through.
"I had a great opponent today [Monday]. He deserved to win this grand slam more than anybody, I'm sure, because over the years he's been a top player.
"He's been so close, lost four finals. Now he has won it, so I would like to congratulate him. I'm definitely happy that he won it.
"He's played so consistently well and won against the top players many times on many surfaces. He has proven today that he's a champion and he deserves to be where he is, no question about it."
Watch: Murray claims first Grand Slam title... More Videos
The match was played in windy conditions, which Murray certainly coped with better, for the first two sets at least.
Djokovic had struggled badly in his semi-final against David Ferrer on Saturday before the match was postponed because of the threat of a tornado, but he did not use it as an excuse.
The Serb said: "He played well. It was a struggle for both of us to deal with the conditions. At times we made a lot of unforced errors, at times we played some great points.
"The two sides of the court were different. Playing with the wind and against the win is a huge advantage or disadvantage. But it was the same for both of us.
"The beginning of the fifth set was the turning point, it was crucial. I should have not lost the two breaks in a row. After that, it was really tough to come back."
It was the first grand slam meeting between Murray and Djokovic since their Australian Open semi-final in January, which also went to five sets.
On that occasion it was Djokovic who came out on top but Murray beat him at the Olympics in their last meeting a month ago, and coach Ivan Lendl has had a major impact on the Scot since they began working together at the start of this year.
Djokovic believes the main change has been in his rival's head, adding: "He has made maybe a couple of adjustments in his game. Maybe he goes for his forehand more than he used to.
"But he was always one of the best players to play in the men's game the last couple of years. It was always a challenge to any of us on any surface. I think it was mental for him in the end to really make a breakthrough."