Desperation and pressure, those evil twins, gnawed away at Novak Djokovic’s spirit to lift the emotional Serb to his second Wimbledon triumph on a warm Sunday afternoon, a strangely mellow setting for such an elemental fight with the people’s champion, Roger Federer.

Those who cried with and for the loser, the most popular man in the history of the game, might spare a thought, too, for the winner because, had he lost a sometimes excruciating struggle, the psychological damage could have been significant.

Although he was a slight favourite (how often can a man with 17 majors start as an underdog at Wimbledon?), although he had five years on his opponent, although the sentiment was with Federer, reaching for an 18th slam title after a two-year drought, it was Djokovic who was carrying the greater burden.

If Federer had won, it would have been hailed as the crowning achievement of a glorious career. Losing hardly dented his aura or his legacy, especially as he went down fighting.

But for Djokovic, a sixth defeat in seven slam finals, to complete four in a row, was unthinkable. He simply could not allow it – even though no one was pulling for him. To lose – even to the man he later described as “a magnificent champion” – could have induced serious despond. Indeed he had said beforehand his inability to close out these big occasions was “wholly psychological”.

He was drained as few could remember after Andy Murray beat him in three sets in last year’s final. This was about personal redemption.

So Djokovic deliberately put that pressure on himself, to give himself a frightening edge, and that potent mix of emotions most assuredly played with his mind at key moments in this match, which he won 6-7, 6-4, 7-6, 5-7, 6-4, holding off a heart-pumping comeback in the fourth set by Federer, when most reckoned his 32-year-old legs would be turning to jelly.

For all that victory rescued Djokovic from a slide towards self-doubt, he will celebrate a greater occasion on Thursday, when he marries Jelena Ristic at a secret location on an island off Montenegro.

Very few players are among the 210 guests. While tennis obsesses Djokovic, it does not rule his life. Jelena is also expecting their first child in October. If those two events cannot put the champion’s tennis in perspective, nothing can – and there is every chance that, as with the man he beat on Sunday, the still smiling father of two sets of twins, domestic calm will bring order to his tennis as well.

“I would like to dedicate it to my future wife and our future baby,” Djokovic said on court. “I’m going to become a father soon and I’m still preparing for that. It’s a great joy in life.”

But Sunday was a work day. Jelena was at home and he had for immediate company a man trying, metaphorically, to rip his head off.

It was an imperfect contest, certainly, but brilliant for all that, dipping and soaring through three times as many winners as unforced errors. Djokovic made Federer run 4,096 metres, and he put in a mere 3,773 metres. At the end they might each have weighed half a stone less than when they started.

Neither player was entirely comfortable in a ragged, nervy start, even though they had swapped many thousands of shots in their previous 34 encounters. While there can have been little they did not know about each other’s tennis, neither man could be certain, from shot to shot, what was coming next.

Nor, of course, could anyone else. The closeness of a final – the first here over five sets since Federer beat Andy Roddick in 2009 – ensured a sense of theatre from the first fault off Djokovic’s racket at 2.10pm to the final, weary Federer backhand that billowed the net three hours and 56 minutes later.

It was an odd contest to read. Djokovic lost the first set in a tie-break, blowing chance after chance as Federer struggled to take points off his opponent’s serve. And it was the Federer serve that was to prove a revelation.

He has always been superb with ball in hand but here he raised his level yet again, adding 29 aces to the 69 he had gathered in the previous six matches. If he had managed a couple more, we might have been celebrating a Swiss victory.

Djokovic, whose own serve Boris Becker has been working on since becoming his coach this year, did not click with anything like that potency but he made Federer suffer with the sheer strength and precision of his ground strokes, particularly his backhand down the line that often left his opponent embarrassingly rooted to the spot.

By the time Djokovic had established what against anyone else would have been a decent lead, two sets to one and 5-2, with his hands almost on the trophy, a certain sadness fell on the occasion. Would this be a wickedly one-sided ending? Not quite, it turned out.

Federer, drawing on every ounce of his pedigree, saved match point, broke and earned himself another shot at the prize. He prevailed again. Djokovic’s legs then went on him in the fifth – literally, as he required courtside massage to his calves. The finish promised to be ugly.

Djokovic, who had taken two heavy tumbles and a couple of less serious falls, held for 2-1 in the fifth but was limping. All of a sudden, as the ATP physio went to work on his right calf, the vivacity was with the older man. Federer was not just turning back the clock, he was Father Time, in charge of the rhythm of the exchanges now, looking younger by the second, reborn in his own golden image.

With seven Wimbledons to his name, Federer knew what he needed to do on the tricky, wearing grass at the end of tournament fortnight, but the tension got to him as well. After one break of service in four sets, five arrived in the fifth and the congregation had not a clue until near the very end who would win.

Federer saved three break points at 3-4; at 4-5 he let Djokovic back into it when his serve finally let him down. Djokovic stretched his chest, steadied his arm and reckoned he could do this job.

Serving to stay in the match, Federer finally cracked.

“I respect your career and everything you’ve done,” Djokovic told him immediately afterwards, “and thank you for letting me win today. After dropping a fourth set it wasn’t easy to regroup and find the energy to win the fifth. I don’t know how I did it.” He is probably right. And that is the wonder of it all.