STUTTGART, Germany (AP) Roger Federer squandered two match points and lost to Dominic Thiem 3-6, 7-6 (7), 6-4 in a rain-interrupted Mercedes Cup semifinal on Saturday.

Thiem will play seventh-seeded Philipp Kohlschreiber for the title. Kohlschreiber beat Juan Martin del Potro 6-3, 6-4 in a match that had a long rain delay in the second set.

Thiem led 5-0 in the second set before allowing the top-seeded Federer to pull even by winning five straight games. In the tiebreaker, Federer wasted one match point with a smash into the net. On the second, he tried to serve and volley behind a second serve but was passed by an impeccable return. Thiem won the set with a smash.

''I was incredibly nervous. I was fortunate in the tiebreaker but you need good luck to beat the best player on grass,'' Thiem said.

Thiem beat Federer in the third round of the Italian Open before Federer took a month off to deal with a back injury. That win was on clay, while Saturday's came on grass, Federer's favorite surface.

''I can't believe that I beat him on grass,'' said Thiem, who has little experience on grass. Federer is a seven-time Wimbledon champion.

Thiem won the match when Federer sent a backhand wide on Thiem's second match point. The match was twice interrupted by rain, both times for 30 minutes. The second delay came right after Thiem broke for 4-3 in the third set.

Federer is still without a title this year. He had knee surgery after losing in the semifinals of the Australian Open to Novak Djokovic and was forced to skip the French Open because of the back injury. He's ranked No. 3.

Thiem, with three ATP titles this year, reached his maiden Grand Slam semifinals at the French Open, and the Austrian has jumped to No. 7 in the world.