Rafael Nadal defeated Italian Fabio Fognini 7-5 7-5 to win the Hamburg Open and clinch his third title of the year.
Nadal, playing in his first tournament since Wimbledon, had already lost to Fognini twice on clay this year.
But he won a tight final that saw 12 breaks of serve to extend his run of having won a European clay-court tournament every year since 2004.
It is the 67th singles title of the 29-year-old's career and his third in Hamburg, where he last won in 2008.
"It was a very tough final, it is an important title for me" said Nadal, who suffered cramp as he tried to conduct a post-match interview on the court.
Nadal, who has suffered from injuries this season, had not competed since he was knocked out of Wimbledon in the second round by qualifier Dustin Brown.
The Spaniard squandered a 3-1 lead in the final set but saved two set points before finally defeating the eighth seed in two hours 34 minutes.
"It was a great match, many great points, many breaks, we fought hard," added Nadal, who now has 47 titles on clay and will move up to ninth in the world rankings on Monday.