His strokes awry, his emotions laid bare for all to see, Roger Federer figured out a way to stay in the U.S. Open on Tuesday, rallying to beat 23rd-seeded Igor Andreev of Russia 6-7 (5), 7-6 (5), 6-3, 3-6, 6-3 to reach the quarterfinals at the year's last Grand Slam.

Federer found himself locked in a five-set struggle against the sort of player the world is accustomed to seeing him dismiss with ease, and it was only near the end that the four-time defending champion at Flushing Meadows looked the part.

"Being down a set, and a tiebreak in the second set, obviously, you know, there's danger written all over that situation," Federer said. "You just hope that it's going to turn your way. It did."

When he finished the match with a forehand winner, Federer shook his fists violently and yelled, then flashed a grin toward his girlfriend and others in his guest box.

Hard to recall the last time this guy was so pleased by a mere fourth-round victory. Federer Federer is, after all, a man who owns 12 Grand Slam titles, two short of Pete Sampras' career mark. A man who has won 31 consecutive matches at the U.S. Open. A man who is trying to extend his record streak of 17 straight appearances in major semifinals.

And yet Federer couldn't stop smiling at the end of the 3 1/2-hour test, in part because, he explained, he found it fun to be pushed into a fifth set.

"I don't give myself the opportunity that much, you know, because I always win easily," he said. "I was just really pleased with my fighting spirit."

Serbian third seed Novak Djokovic felt the same way about his five-setter earlier Tuesday when he overcame No. 15 Tommy Robredo of Spain 4-6, 6-2, 6-3, 5-7, 6-3. When the victory was over, the 2007 runner-up to Federer at the U.S. Open and the reigning Australian Open champion looked up in the stands and saw his mother pounding her chest repeatedly.

Djokovic responded in kind, bumping a closed fist over his heart four times, then using his right index finger to point there, point to each knee and point to his temple — looking up into the stands all the while.

"Just trying to show them, you know, how much effort I put into this match," Djokovic said.

He needed every ounce of heart, smarts and energy he could muster, and acknowledged that his quarterfinal foe — 2003 U.S. Open champion Andy Roddick of the United States, who overpowered No. 11 Fernando Gonzalez of Chile 6-2, 6-4, 6-1 at night — would be fitter.

"I've got to feel good," Roddick said, thinking ahead. "He's got about 16 injuries right now."

Because the Federer and Djokovic matches lasted so long, the women's quarterfinal between No. 2 Jelena Jankovic of Serbia and Austrian No. 29 Sybille Bammer was moved from Arthur Ashe Stadium to Louis Armstrong Stadium. Jankovic won 6-1, 6-4, advancing to a semifinal against No. 5 Elena Dementieva of Russia, who beat No. 15 Patty Schnyder of Switzerland 6-2, 6-3.

Jankovic was happy about the court switch, she said, "because we would have to wait a long time for Federer to finish."

That surprised everyone, even if Federer's 12 losses already are more than he absorbed in any entire season from 2004-07. The standards he has set are so high that any misstep is fodder for questions about the state of his game — and his career.

Still, it's one thing to lose to Rafael Nadal, the man who walloped Federer in the French Open final and edged him in a five-set thriller of a Wimbledon final. Nadal owns five Grand Slam titles and has overtaken Federer in the rankings after the Swiss star's record 237-week stay at No. 1.

It would have been quite another thing to lose to Andreev, someone who showed up at this U.S. Open with a career mark of 2-3 at the place, someone who has only once made it as far as the quarterfinals at any major tournament, someone who entered Tuesday on a seven-match losing streak against players ranked in the top five.

"For me, it was great experience," Andreev said, "and hopefully, like, in the future is going to help me."

He fell to 1-7 in five-set matches, and big-match toughness certainly was a factor at key stages.

That also could be the case when Federer plays 130th-ranked Gilles Muller in the quarterfinals Thursday. The only man from Luxembourg to play Grand Slam tennis knocked off No. 5 Nikolay Davydenko of Russia 6-4, 4-6, 6-3, 7-6 (10) to become only the second qualifier to reach the U.S. Open quarterfinals.

Asked about facing another player who doesn't carry any burden of expectations into a match against him, Federer shrugged and said: "It's been like this for 4 1/2 years. This is nothing different for me. It's just a guy who's got even less to lose."

Scurrying along the baseline to whip his go-for-it forehand and find a line, Andreev managed to make the once-invincible Federer seem human — not just during points, but between them.

Normally so calm, so collected, Federer often threw his head back in disappointment or screamed with delight. He pulled a ball out his pocket and chucked it. He cracked another ball into the net after one lost opportunity.

But in the second set, Andreev accumulated seven break points — and Federer saved them all. Any one of those could have swung the match for good. And in the crucible of the fifth set, Andreev compiled four more break points, all with Federer serving at 4-2 — and, again, Federer handled the situation better, erasing every one.