LONDON — Top seed and defending champion Novak Djokovic will try for his fifth Wimbledon title on Sunday after beating No. 23 seed Roberto Bautista Agut of Spain 6-2, 4-6, 6-3, 6-2 in Friday's first semifinal at the All-England Club.

He will face Swiss great and No. 2 seed Roger Federer, who outlasted No. 3 Rafael Nadal of Spain 7-6 (3), 1-6, 6-3, 6-4 in their 40th career meeting in the other semifinal.

After winning the first set in a tiebreak, Federer struggled after missing an early break in the second set and Nadal dominated the rest of the way. The third set saw the rivals trade holds again, until Federer managed his first break of the match in the fourth game to take a 3-1 lead. Both players held the rest of the way as Federer moved one set away from a spot in the finals.

Federer again broke Nadal early in the fourth set and held on late to avoid being pushed to a fifth set.

"I'm exhausted," Federer said after the match, which lasted three hours, six minutes. "It was tough at the end. Rafa played some unbelievable shots to stay in the match. I thought that the match was played at a very high level, and I enjoyed it. The crowds were amazing and the battles with Rafa are always very special. So it was nice."

The match marked the 32nd time the winner of the first set has won the match in their rivalry.

"I think I had spells where I was serving very well," Federer said. "I thought probably the biggest points in the match went my way. There were some tight ones and long ways and plays with such velocities and spins and everything, you're not sure if you're going to connect the right way. Like at the very end when he saved match points, those are the kind of points that I'm talking about. I think those went more my way than his."

It also marked the second consecutive grand slam tournament in which Djokovic, Federer and Nadal all reached the semifinals — Nadal prevailed in June for his 12th French Open title — after the trio previously hadn't done so since 2012 at Roland Garros.

Nadal beat Federer in straight sets in the French Open semifinals last month, but the two hadn't met at Wimbledon since 2008, when Nadal prevailed in a five-set thriller to claim his first title at the All England Club. It was their fourth meeting overall at Wimbledon, with Federer also winning in the 2006 and 2007 finals.

Nadal leads the all-time series 24-16, though Federer had won six straight before the semifinal loss at Roland Garros.

Bautista Agut had beaten Djokovic in both of their prior meetings this year, but had never faced the Serbian star on grass. With Friday's win, Djokovic now leads their rivalry 8-3.

After Djokovic cruised through the opening set, Bautista Agut picked up a break early in the second set and held the rest of the way to even the match.

In the third set, both players held until the sixth service game, when Djokovic earned his first break opportunity since the first set and took full advantage to go up 4-2 and seize the momentum.

After a marathon hold to open the fourth set, Bautista Agut dropped his next two service games to fall behind 4-1. In the final game, Bautista Agut fought off four match points before finally succumbing.

Djokovic improved to 71-10 at Wimbledon, two days after becoming just the fourth man in the Open Era to reach the 70-win mark, joining Federer, Jimmy Connors and Boris Becker.

"I have a chance to fight for a trophy," said Djokovic. "Regardless of who's across the net or what is happening, I'll definitely give it my all."

Djokovic is 25-22 in his career vs. Federer, including victories in the finals at Wimbledon in 2014 and 2015.

"Novak is supreme again," said Federer. "He's the defending champion, and he's showed why this week. He has been rock solid from start to finish so far. I hope I can push him to the brink and hopefully beat him, but it's going to be very difficult as we know. He's not No. 1 by chance."