If Roger Federer is to win the 100th tournament of his 20-year career here this week, he will need to rediscover some of his renowned composure after an unusually frenetic two-set loss to Kei Nishikori on Sunday evening. It was the first time in 15 visits to the end-of-season ATP World Tour Finals that the six-times champion has lost a round-robin match in straight sets.

He even picked up a rare code violation, thrashing the ball into the crowd after failing to read and reach a subtle tap down the line when he had Nishikori under pressure in the 11th game of the first set, serving at 5-6 and 15-30.

When Federer then hit the ball into the crowd in frustration, the experienced Argentinian umpire, Damian Steiner, was less than pleased and Federer could not hide his anger at the sanction.

The incident seemed to unsettle his game – not to mention the comfort of his adoring audience – and he went on to lose the tie-break, the set and the match. His sometimes fragile Japanese opponent steadied his nerves for a 7-6 (4), 6-3 win in just under an hour and a half that eases him into the second round of their group in good shape against Kevin Anderson, who earlier beat Dominic Thiem in straight sets. Thiem will play Federer on Tuesday.

Federer, who was already in his press conference even as Nishikori was completing his on-court TV interview, said of the incident: “I thought, what was his argument, you know? Why the warning? But nothing more than that. He thought I was angry. I wasn’t. Now I’m angry because I lost. He knows me very well, apparently – or he thought so …”

Asked if he had been joking earlier about being out of sorts in practice, Federer said: “I’ve been feeling fine. It’s just that practice has been a bit all over the place, [at] Queen’s, on the outside courts here, then centre as well. So it’s not always exactly the same conditions. Overall, I think I’m hitting the ball OK.”

The evidence, though, suggests vulnerability. Broken early in the second set, Federer dug himself out of a hole to stay in the fight after they had exchanged early breaks. He held serve to 15 to trail 3-5, but Nishikori – who had beaten Federer only twice in nine previous encounters – sensed this was his time. He raced to 40-love and three match points with a strong serve wide to the forehand and tried for the grandstand finish on the deuce side, but shoved it wide.

Federer scrambled a point off the second serve before a wobbly forehand return from a few feet beyond the baseline ballooned long and Nishikori, seeded seventh of eight finalists, was on the board.