Roger Federer's competitive preparation before Wimbledon ended with a three-set defeat by Canada's Felix Auger-Aliassime at the Halle Open in Germany.
Swiss world number eight Federer, who turns 40 in August, lost 4-6 6-3 6-2 against 20-year-old Auger-Aliassime.
After an encouraging start, Federer struggled on serve in the deciding set as Auger-Aliassime broke twice.
The 20-time Grand Slam champion is going for a record ninth men's singles title at the All England Club.
On Monday, Federer beat Belarusian Ilya Ivashka in straight sets - his first match since pulling out of the French Open to protect a knee injury.
But he found the going much harder against 21st-ranked Auger-Aliassime, who dominated on serve and returned well to keep Federer regularly under pressure.
The event was only the 10-time champion's fourth tournament since January 2020, having needed two surgeries on a knee injury.
Next he will turn his attention to Wimbledon, which starts in south-west London on 28 June.
Auger-Aliassime said Federer was his idol growing up, describing earning a win over him as "amazing".
"It was a huge honour to play him before he retired and to beat him is a moment that I will always cherish," said the Canadian.
"I always thought he'd be gone when I arrived because he was winning Grand Slams when I was like five years old.
"I never expected to play him. To be in the same court as and get the win is a huge honour."