Borna Coric denied Roger Federer the 99th title of his career on Sunday with a 7-6 (8/6), 3-6, 6-2 victory in the final of the ATP Halle grass court event.
Federer also lost the world number one spot in the ATP world rankings to Rafael Nadal heading into Wimbledon, and missed a chance to earn a record 10th title at the German venue.
"Winning always feels good, losing should hurt and it does a bit," 20-time major winner Federer said. "I played what I thought was my best match of week today.
"I didn't play badly, but it didn't go my way, that's unfortunate.
"I leave with my head held high, I had a good run between Stuttgart (grass title last weekend) and Halle."
Coric, the Croatian outsider ranked 34th, also ended Federer's 20-match win streak on grass which stretched to June, 2017.
The loss, in just over two hours, came a week after Federer won his 98th title in Stuttgart.
"It's been an unbelievable week for me," said Coric. "I came here to just get a few matches before Wimbledon.
"I never imagined reaching the final and beating Roger.
"It's an honour just to share the court with him, it's so special, I've always looked up to him and I remember watching him play with my parents -- now I'm playing him."
Coric, who accounted for German second seed Alexander Zverev in the first round, held his nerve against the crowd favourite at the venue which styles itself after the All England Club.
The 21-year-old had lost twice to Federer, but pushed him all the way in their last meeting at Indian Wells in March.
He was the first Croatian to reach the final at Halle and he now owns two titles after winning in Marrakech in 2017.
Federer dropped the opening set, won the second but was unable to fight back after going down 2-4 in the third.
Coric moved out to 5-2 and completed his upset on a second match point a game later as a Federer volley hit the top of the net.
The Swiss fired a dozen aces but lost serve twice.
Federer's excellent serving in the first set -- four love games, three points lost on serve -- could not prevent Coric taking the opener in 57 minutes.
The Croatian withstood a Federer assault in the 11th game, which lasted for nearly 10 minutes and featured five deuces. A game later, the Swiss seed took the set into a tiebreaker.
Federer reached a 5-3 margin and sent down his fifth ace to earn a pair of set points.
But Coric wiped out the first with a service winner while a wild Federer backhand accounted for the other. Seconds later, the Croatian seized the set on his first opportunity from a Federer backhand long.
"I tried to keep it calm, not get over-excited," Coric said. "We both served well.
"A couple of points decided the match. I was lucky in the (first set) tiebreaker. If I had lost the opening set, it would have been tough for me to win.
"Now I just want to rest and prepare for Wimbledon."