WIMBLEDON, England — When he won the greatest match in tennis history, weathering rain delays and encroaching darkness to defeat world No. 1 Roger Federer in the 2008 Wimbledon final, Rafael Nadal collapsed on his back in exhaustion, relief and disbelief.

Friday marked a reprise 11 years on, with a place in Sunday’s final at stake.

This time, it was Federer who won the day on the threadbare grass of Centre Court, turning back time, four weeks shy of his 38th birthday, to defeat his career-defining rival, 7-6 (7-3), 1-6, 6-3, 6-4.

With it, Federer advanced to Sunday’s final, where world No. 1 Novak Djokovic awaits.

If the third-ranked Swiss can pull off the upset, he’d claim the 21st major title of his career, and a ninth Wimbledon championship, putting his record mark even further out of reach from Nadal, who has 18 majors, and Djokovic, with 15.

Federer raised both arms in triumph upon vanquishing Nadal, who fended off four match points before succumbing.

From the moment the All England Club opened its gates Friday, the mood on the grounds was electric. Stars of screen and sport took their place in Centre Court’s Royal Box, while thousands of tennis fans jammed onto Henman Hill to await a reprise of the 2008 Wimbledon final on an oversize TV screen.

Though it was the 40th time the two had met, it was only their fourth match on grass — all three previous coming in Wimbledon finals.

In terms of anticipation, the Djokovic-Batista Agut semifinal felt like an undercard compared to the Federer-Nadal clash in store.

Nadal could barely contain himself when he and Federer took the court at 4:30 p.m., bouncing like a boxer during the coin toss. Federer projected serenity.

What unfolded on Centre Court was a battle of excellence vs. excellence. With neither able to assert an upper hand early, the opening set was settled by a tiebreak. Federer took it, 7-3.

If anything, the early setback stoked Nadal, who ramped up the pressure on Federer’s serve and leveled the match by claiming a 37-minute second set.

At that stage, it wasn’t clear if Federer, just four weeks shy of his 38th birthday, was conserving energy or feeling fatigue.

The Swiss quickly made clear it was the former. He conjured magic in the third set: winning a battle of wits and reflexes at net to break Nadal early, then fending off a clutch of break points to maintain his advantage.

Federer seemed to have an answer for every situation, whether well-placed lobs, irretrievable overheads or unreturnable serves. He also won the long rallies, typically Nadal’s strong suit, scarcely putting a foot wrong.

By the time Federer served for the third set, just past the two-hour mark, shade had crept across all but a small corner of the court. He held with ease, presenting Nadal with a must-win, fourth set.

While Nadal battled on, he never reclaimed the momentum.

Federer remained in control, almost maddeningly serene as Nadal fended off four match points to force the Swiss to serve for the match, at 5-4 in the fourth set.

Earlier Friday, Djokovic, Wimbledon’s four-time and defending champion, was forced to produce his best tennis of the tournament to defeat Roberto Bautista Agut, 6-2, 4-6, 6-3, 6-2, who nearly proved a disrupter in his first Grand Slam semifinal.

Djokovic, 32, had faced only one seeded player (David Goffin) in breezing to Wimbledon’s final four after early-round upsets bounced four top-10 players from his half of the draw.

Bautista Agut, 31, was the final hurdle in reaching the final. By ranking (22nd), he should not have presented much of a threat to Djokovic, who had won three of the previous four Grand Slam.

Seeded 23rd, Bautista Agut was as surprised by his march to Wimbledon’s semifinal as anyone, having scheduled his bachelor party in Ibiza for the tournament’s final weekend. The party was postponed, and his buddies flew to England to join Bautista Agut’s fiancee in cheering him on.

Djokovic claimed the opening set in just 36 minutes, looking virtually untouchable.

But with Djokovic’s forehand and focus straying, Bautista Agut took the second set, 6-4, to level the match at one set each. With the Spaniard making it a match, Djokovic flapped his arms at the capacity crowd in an effort to coax a show of support.

He found his own motivation in the third set and rolled to the victory, clearing the stage for Federer vs. Nadal.