Up until today, Kei Nishikori had beaten exactly one Top 40 player on clay. That was Mardy Fish—who was never accused of being a clay-court expert by anyone—whom Nishikori eliminated in Houston way back in 2011.

But today Nishikori earned some street cred in the dirtballing crowd by taking out a clay-court player of a higher order—defending champion and four-time French Open runner-up Roger Federer. The score of this third-round match was 6-4, 1-6, 6-2, and it will be memorable mostly to those amateur historians who set out to chart the gradual but inevitable demise of the 31-year-old all-time Grand Slam singles titlist.

This is the first time Federer has failed to make the quarterfinals or better in Madrid—in his entire career.

Nishikori is a gritty, tough, emotionally stable player who likes to grind but also counter-punch on hard courts. His problem on clay is that his serve is more vulnerable, and the relatively slow pace of play enables his opponents to stay in points longer and (often) exert their superior strength. Clay takes away the counter-puncher’s element of surprise and quick-strike capability, and that’s a lot to have to give up.

Today, though, Federer started sluggish and, despite a mid-match revival, finished slow—classic symptoms of an aging player who no longer wants to win in his heart, just in his mind; thus, he has to force himself to want to want to win. But credit Nishikori for taking advantage of the opportunity, for many ATP pros would still have been too star-struck to do so, especially after the way Federer came roaring back in the second set.

One of the first signs that Nishikori was up to the job offered him was the way he took immediate advantage of the first break point that either man saw, with Federer serving at 2-2 in the first set. After a brief rally, Nishikori smacked one of his many inside-out forehand placements to secure the break. It would be the only point of crisis until Nishikori reached set point in 10th game with another inside-out, unreturnable forehand. He won the set when Federer hit one of the numerous shanked backhands that characterized his day.

Nishikori had taken a big step, but watching him for a reaction, you wouldn’t have known it. There was no fist pump, no shout of “Come on!” or a similar exultation. But there was resolve, and Nishikori would need it.

Federer popped to life in the second set. Where earlier it appeared that he was just going through the motions—reluctant to attack, disinclined to grind, ignoring some of the most useful items in his toolbox—in the next set he began to pepper Nishikori’s side of the court with shots of varying pace and depth, including a flurry of drop shots and passing shots (after he’d lured Nishikori to the net).

Nishikori survived two break points to level at 1-1 in the second set, but after a quick Federer hold, the No. 14 seed lost concentration. He made three puzzling unforced errors, but then pulled himself together to sweep away the three break points, mostly through good serving. But at deuce, Federer delivered an unreturnable drop shot and secured his first break (on his sixth break point of the match) thanks to a  Nishikori error.

For a while after that, we had glimpses of the “full-flight Federer” of yore as he closed out the set in 32 minutes.

Federer got off to a good start in the final set, too, hitting a pair of aces to level at 1-all. In the next game, he went up 30-love with a down-the-line backhand placement—and then his wheels fell off. Nishikori hit three consecutive serves to Federer’s forehand and never saw the ball come back in bounds. A forehand error lifted Federer to deuce, but a bang-bang service winner and backhand service-return error saved the game for Nishikori. It was one in which Federer was unable to return five of Nishikori’s generally returnable serves.

In the very next game, Federer sandwiched three errors around a service winner to face double-break point. He survived the first one with a service winner to the backhand, but then clubbed a forehand out off Nishikori’s service return to surrender a break. It was Federer’s fourth unforced error of the game that finally and irrevocably turned the tide.

After that brace of shocking games, the end seemed foreordained. The major question was whether Nishikori would choke, not an impossible scenario given the struggles he’s had on clay. But while Federer continued to spray balls all over the place, Nishikori kept his cool and ultimately secured the match—getting one last forehand error out of an oddly muted Federer at match point.

Stat of the Match: Federer won all seven points he played at the net. Why he didn’t attack more often, especially in light of his struggles off the ground, is a mystery.