Swiss second seed Federer, seeking his 17th Grand Slam crown and a seventh consecutive trip to the US Open final, eliminated Germany's 104th-ranked Andreas Beck 6-3, 6-4, 6-3 in one hour and 41 minutes at Arthur Ashe Stadium.
Federer, a five-time US Open champion, will face the winner of a later match between Frenchmen Guillaume Rufin and Paul-Henri Mathieu to decide a berth in the last 16 on the Flushing Meadows hardcourts.
Federer jumped ahead 5-0 in only 12 minutes, claimed the first set in 27 minutes despite surrendering a break and was seldom threatened.
Russian Davydenko, a 2006 and 2007 US Open semi-final loser to Federer, was pounded 6-3, 6-4, 6-2 by 38th-ranked Richard Gasquet, who will next face either South African Kevin Anderson or Brazilian 26th seed Thomasz Bellucci.
Gasquet, among a record 12 Frenchmen to reach the second round, lost only seven of 52 points on his first serve as Davydenko made his quickest US Open exit since 2005.
Davydenko joined a US Open seeded scrap heap that includes No. 7 Tomas Berdych of the Czech Republic, US ninth seed Andy Roddick and Croatia's Cilic, who dropped the longest match of the week just 60 seconds shy of five hours.
Nishikori, ranked 147th, fought off cramping in the hottest day of a scorching week to defeat Cilic 5-7, 7-6 (8/6), 3-6, 7-6 (7/3), 6-1 in an exhausting duel.
"I don't know how long I've played now. I'm pretty tired," Nishikori said. "I was cramping from the second set but I kept fighting and fighting and got the fourth set tie-breaker. That was key for me. It was a great match.
"It was hot but I feel good now."
The triumph, Nishikori's fifth in a week counting qualifying matches, came on the same Grandstand court where Japan's Shuzo Matsuoka writhed in cramping agony in 1995, left unaided lest he be defaulted in a move that led to changes in medical treatment of players.
"I've seen it many times," Nishikori said of the video. "It was sad to see him like that. No one can help."
Cilic, who reached his first Grand Slam quarter-final at last year's US Open and advanced to this year's Australian Open semi-finals, edged Nishikori for the first set and blasted an ace for a 6-5 lead in the second set tie-breaker.
Nishikori, 20, answered with a forehand smash to level and then fired an ace of his own, one that sparked complaints that the ball was wide from Cilic, who then double faulted to squander the set and slammed down his racket in anger.
Cilic, 21, won the only break-point chance of the third set with a backhand winner in the eighth game to reclaim the advantage.
Nishikori, whose run to the fourth round in 2008 was his best Slam showing and the best US Open showing by a Japanese man since 1937, jumped to a 4-1 lead in the fourth set before Cilic broke back and they held into a tie-breaker.
Nishikori hit a drop volley winner for a 6-3 tie-break edge and forced a fifth set when Cilic sent a crosscourt backhand wide.
Cilic surrendered a break to open the last set and another in the fifth to give Nishikori a 4-1 edge and the Japanese star broke again for the match with both men weary.
US 19th seed Mardy Fish, who won twice in July and reached the final of the last major US Open tuneup at Cincinnati, fired 14 aces and reached the third round by eliminating Uruguay's Pablo Cuevas 7-5, 6-0, 6-2.
Next in Fish's path is France's Arnaud Clement, the oldest man still in the event at 32. Clement advanced in 96 minutes, leading 6-3, 5-5 when Argentina's Eduardo Schwank retired with an ankle injury.
"I've never put myself in position to be a guy who is talked about at a Grand Slam," Fish said. "I'd love another crack at a top-5, top-10 player in a Slam. I've beaten a couple but not deep into a tournament.
"Getting myself in position to play a Djokovic or Davydenko, I certainly feel like I can win."
Source: AFP American Edition