New York - Roger Federer needed a second successive five-setter to reach the US Open third round on Thursday with a 6-1, 6-7 (3/7), 4-6, 6-4, 6-2 win over fellow veteran Mikhail Youzhny of Russia.
It was the Australian Open and Wimbledon champion's 17th win in 17 matches against Youzhny in a rivalry stretching back to 2000.
Five-time US Open champion and third seed Federer had also needed five sets to see off US teenager Frances Tiafoe in the first round.
The 36-year-old, who now has 80 match wins at the US Open, will face 35-year-old Feliciano Lopez of Spain for a place in the last 16.
His record against Lopez is just as solid - 12-0.
"It was quite a lot of fun out there - I feel quite warmed up by now," said Federer who fired 63 winners and 68 unforced errors.
"Looked liked Mikhail was cramping at the end and that was hard to watch.
"We played in the doubles here back when we were juniors and have met loads of times. This was probably the best match we have played against each other."
There was no sign of the drama to come when Federer sprinted through the opener in just 25 minutes on the back of two breaks of serve on the Arthur Ashe court.
But Youzhny held firm with a break as the Swiss star served for a two-sets lead in the 10th game and levelled the match with a steady tie-break.
Federer appeared increasingly sluggish, a possible legacy of his recent back problems, and despite saving two set points in the ninth game, Youzhny pounced in the next to claim the third set.
The momentum swung again in the fourth when Youzhny, just a year younger than Federer at 35, required a medical timeout.
Federer levelled the contest as he went into back-to-back five-setters in the opening two rounds of a major for the first time in his career.
Youzhny began to cramp and was broken in the sixth game as his challenge fizzled out.
Results from day 4 of the US Open on Thursday (x denotes seeding):
Rafael Nadal (ESP x1) bt Taro Daniel (JPN) 4-6, 6-3, 6-2, 6-2
Leonardo Mayer (ARG) bt Yuichi Sugita (JPN) 6-7 (3/7), 6-4, 6-3, 6-4
Viktor Troicki (SRB) bt Stefano Travaglia (ITA) 7-6 (8/6), 7-5, 6-0
Aleksandr Dolgopolov (UKR) bt Tomas Berdych (CZE x15) 3-6, 6-1, 7-6 (7/5), 6-2
David Goffin (BEL x9) bt Guido Pella (ARG) 3-6, 7-6 (7/5), 6-7 (2/7), 7-6 (7/4), 6-3
Gael Monfils (FRA x18) bt Donald Young (USA) 6-3, 6-7 (3/7), 6-4, 2-6, 7-5
Damir Džumhur (BIH) bt Cedrik-Marcel Stebe (GER) 4-6, 6-4, 6-0, 6-1
Andrey Rublev (RUS) bt Grigor Dimitrov (BUL) 7-5, 7-6 (7/3), 6-3
Roger Federer (SUI x3) bt Mikhail Youzhny (RUS) 6-1, 6-7 (3/7), 4-6, 6-4, 6-2
Feliciano Lopez (ESP x31) bt Fernando Verdasco (ESP) 6-3, 6-2, 3-6, 6-1
Philipp Kohlschreiber (GER x33) bt Santiago Giraldo (COL) 6-2, 6-1, 3-0 - retired
John Millman (AUS) bt Malek Jaziri (TUN) 6-1, 7-6 (7/1), 6-1
Roberto Bautista Agut (ESP x11) bt Dustin Brown (GER) 6-1, 6-3, 7-6 (7/3)
Juan Martín Del Potro (ARG x24) bt Adrián Menéndez (ESP) 6-2, 6-3, 7-6 (7/3)
Adrian Mannarino (FRA x30) bt Bjorn Fratangelo (USA) 6-3, 6-7 (4/7), 6-1, 6-2
Dominic Thiem (AUT x6) bt Taylor Fritz (USA) 6-4, 6-4, 4-6, 7-5
Karolína Plíšková (CZE x1) bt Nicole Gibbs (USA) 2-6, 6-3, 6-4
Zhang Shuai (CHN x27) bt Risa Ozaki (JPN) 6-0, 6-3
Jennifer Brady (USA) bt Barbora Strycová (CZE) 6-1, 6-1
Monica Niculescu (ROM) bt Ana Bogdan (ROM) 6-2, 3-6, 6-3
Agnieszka Radwanska (POL x10) bt Yulia Putintseva (KAZ) 7-5, 6-2
Coco Vandeweghe (USA x20) bt Ons Jabeur (TUN) 7-6 (8/6), 6-2
Lucie Safarova (CZE) bt Nao Hibino (JPN) 6-1, 3-6, 6-2
Kurumi Nara (JPN) bt Svetlana Kuznetsova (RUS x8) 6-3, 3-6, 6-3
Elina Svitolina (UKR x4) bt Evgeniya Rodina (RUS) 6-4, 6-4
Shelby Rogers (USA) bt Daria Gavrilova (AUS) 7-6 (8/6), 4-6, 7-6 (7/5)
Elena Vesnina (RUS x17) bt Kirsten Flipkens (BEL) 6-4, 6-4
Madison Keys (USA x15) bt Tatjana Malek (GER) 6-3, 6-4
Jelena Ostapenko (LAT x12) bt Sorana Cirstea (ROM) 6-4, 6-4
Darya Kasatkina (RUS) bt Christina McHale (USA) 7-5, 6-3
Kaia Kanepi (EST) bt Yanina Wickmayer (BEL) 6-4, 6-2
Naomi Osaka (JPN) bt Denisa Allertová (CZE) 6-3, 4-6, 7-5