Roger Federer will face Novak Djokovic in a record-extending 12th Wimbledon final after overcoming longtime rival Rafael Nadal in an epic three-hour semifinal.

The 40th career meeting, the first grasscourt duel between the two former world number ones in 11 years, swung both ways on Friday before Federer seized control to seal a 7-6(3), 1-6, 6-3, 6-4 victory.

After edging a tense first set by taking the last five points of the tie-break, Federer was overpowered in a 36-minute second set as Nadal, reviving memories of his memorable 2008 final triumph over the Swiss, appeared to have wrestled control.

The eight-time Wimbledon champion Federer took the lead after winning the third set by a single break.

He missed four match points serving to end the contest in the fourth but outlasted Nadal in a final rally.

“I’m exhausted. It was tough at the end. Rafa played some unbelievable shots to stay in the match. The match was played at a very high level,” Federer told the BBC after the match.

“The biggest points in the match went my way. There were tight ones and long rallies… It was a joy to play today.”

World number one and defending champion Djokovic now stands between the 37-year-old Federer, the oldest finalist at the All England Club since Ken Rosewall in 1974, and a record-equalling ninth Wimbledon title which will also seal a record 21st Grand Slam.

Djokovic overcame Spain’s Roberto Bautista Agut 6-2, 4-6, 6-3, 6-2 earlier on Friday to reach his sixth Wimbledon final.

The Serb, a four-time champion, heads into the championship match against Federer with 25 wins over the Swiss and 22 losses.