Federer, soon to turn 33, is running out of time to remain a champion. Gulbis, soon to turn 26, is running out of time to become one.
But only one of them still has a chance to win this French Open, and the surprise - only a mild one at this stage - is that it isn't Federer.
The 18th-seeded Gulbis, a worldly Latvian who has long been one of tennis' top interviews and unrealized talents, was a clear threat in his current state of grace. And although many a man has talked a good game and then lost to Federer, Gulbis' prematch confidence sounded more like realism than bravado.
So it went on another overcast afternoon on Philippe Chatrier Court, where Federer has experienced some serious thrills - his title run in 2009, his semifinal victory over Novak Djokovic in 2011 - but also some great disappointments.
This five-set loss probably won't make the shortlist. But Gulbis' 6-7 (5), 7-6 (3), 6-2, 4-6, 6-3 victory was the latest bitter layer on the mille-feuille of Federer's long, rich career.
The smooth mover who was once a lock to reach the quarterfinals at Grand Slam tournaments has now lost before the quarterfinals in three of the last four.
He was rocked at Wimbledon in the second round last year by Sergiy Stakhovsky and beaten in the fourth round of the U.S. Open by Tommy Robredo. After reaching the semifinals at this year's Australian Open, he has made his earliest exit from Roland Garros in 10 years.
"This one, I felt I was in good form," Federer said, sounding particularly glum. "I really feel I could have done something."
The second set had to be particularly deflating. Federer, serving for a two-set lead at 5-3, failed to convert on two set points, losing the first after controlling the rally and then hitting an overhead back at Gulbis instead of into the open court. Gulbis responded with a backhand winner.
Gulbis went on to win that set and the third set, too. He then fell behind, 2-5, in the fourth before calling for the trainer on the changeover and taking a long medical timeout off the court while Federer waited in his chair and the crowd chanted Federer's first name.
But momentum is more precious in tennis than popularity, and when Gulbis returned, Federer had lost something essential. He dropped two games in a row, and although he held serve to win the fourth set, he dropped the first three games of the fifth, playing a particularly unconvincing service game at 0-1.
There is no rule against taking a medical timeout before another player serves for a set, but it is no way to make friends in the locker room. Federer, who had a similar situation occur in his third-round victory over Dmitry Tursunov, was pressed repeatedly for his opinion of Gulbis' timeout.
"If the rules allow you to do that, you know, what can you do?" Federer said. "That's part of the game. In the past, I guess, it's been abused much more than today, but still, what can you tell? He didn't look hurt in any way. But if you can use it, you know, might as well do it."
Gulbis, who slammed serves and covered court with abandon after the break, said that he was feeling tightness in his lower back and one of his hamstrings and that he was concerned he might pull a muscle if he did not seek treatment.
"I'm not big on medical timeouts," he said. "I don't like to take it, but I take it when it is really necessary."
Federer, seeded fourth, has certainly overcome greater adversity to win matches, but his margins over the chase pack are thinner now, and Gulbis is coming on fast.
Their playing styles are in contrast, Federer all feline grace, Gulbis occasionally brutish effort with a stiff and distinctive forehand windup. But there is plenty of skill and variety in Gulbis' game. He beat Federer with lobs and drop shots, with acute angles and raw, straight-line power. He is 31-10 this season and has won eight straight matches on clay, capturing the title in Nice and reaching the French Open quarterfinals for the first time since 2008.
Back then, it appeared Gulbis might soon follow the lead of Djokovic, with whom he once trained at Niki Pilic's academy in Munich. But as Djokovic continued his rise, Gulbis, who comes from a wealthy family, fell away, struggling for consistency and, by his own admission, struggling to maintain focus and make good decisions.
The turning point came in 2012 when he began training in Vienna at the academy run by Bresnik, who has coached many players with big personalities, including Horst Skoff and three-time Wimbledon champion Boris Becker.
"He's one of the strongest personalities," Bresnik said of Gulbis. "I always compare him a little to Boris, because this has been very helpful to me that I have the experience with a guy like Boris to work with him. You know when to let somebody go and when to pull in the reins. This is the challenge."
Bresnik said he thought Gulbis' two-handed backhand was "genius," as good as Djokovic's or Andy Murray's. But he has no illusions about what is making the difference.
"The main thing is that the last two years he worked, worked and worked," Bresnik said.
Worked to fulfill the potential Bresnik has long known he possessed. Worked, in Gulbis' own words, to catch "the last train" available to the top at age 25.
Bresnik agreed that it could be tougher for children of affluence to possess a hunger for tennis success. But there are clearly excellent exceptions, like Federer and Nadal, both from comfortable backgrounds.
"I do think Ernests loves winning," Bresnik said. "He told me once, 'The only time I'm happy is 10 minutes after I won a match, and then I am already worried about the next one.'"
It must have been a particularly sweet 10 minutes Sunday, after a victory Gulbis called the biggest of his career.
Next worry: No. 6 seed Tomas Berdych. Next worry for Federer: making the quarterfinals at Wimbledon.
Â© 2014 New York Times News Service