It took forever – not literally, but almost – but Roger Federer eventually outlasted Juan Martin del Potro in the longest tennis match in Olympic history.

After 4 hours 26 minutes on court, Del Potro’s desperate backhanded shot hit the net, giving the 17-time Grand Slam champion a 3-6, 7-6 (7-5), 19-17 win. The third set alone last 2 hours, 43 minutes.

Roger Federer secured Switzerland's first medal of the London Games by edging Juan Martin del Potro in an instant classic. (Clive Brunskill/Getty Images)

The match started just before noon London time and nearly lasted until 5 p.m., but no one in attendance – Bill Gates and Kobe Bryant among them – seemed to mind waiting for what was to be the main event between Britain’s own Andy Murray and Novak Djokovic.

Federer and Del Potro broke the record set Tuesday by France’s Jo-Wilfried Tsonga and Canada’s Milos Raonic, whose round-of-16 match lasted 3 hours, 56 minutes. Tsonga eventually won the match 25-23 in the third set.

Federer overcame 41 unforced errors — compared with del Potro’s 34 — on the day, and had a total of 64 winners. Each man pulled out a number of impressive holds in the decisive final set. Tied 9-9, Federer finally broke del Potro’s serve but then couldn’t hold his own and the two were again knotted, this time at 10-apiece.

Then with the third set tied at 14, Federer earned three break points but the big Argentine battled back to extend the match. At 17-all, Federer again gained triple-break-point and after Del Potro saved the first, the Swiss finally capitalized.

Juan Martin del Potro stuck with the world's top-ranked player until the bitter end. (Elise Amendola/AP)

With the victory, Federer, who won his record seventh Wimbledon title on the same court less than one month ago, has secured Switzerland’s first medal at the London Games. Federer was also the top seed at the 2008 Olympics, where he lost to American James Blake in the quarterfinals. Federer’s lone Olympic medal had been a gold earned playing doubles in Beijing. Now in his fourth Olympics, he’s made no secret about his desire to add a gold medal to his career accomplishments.

Del Potro was scheduled to go back on court 90 minutes later for a mixed doubles quarterfinal against Americans Mike Bryan and Lisa Raymond.

Matt Brooks contributed to this report.


Live blog: Follow all of Friday’s action with up-to-the-minute updates

Tennis stars see special meaning in London Games

Wise: Wimbledon? Been there. Got wet.

Federer beats Murray to win seventh Wimbledon title