The world number three beat Russian Mikhail Youzhny 6-7(7/5), 6-3, 6-4 in just over two hours to win his first tournament of the year.
The Swiss however started slowly and failed to convert five break points, while 13 unforced errors helped Youzhny to a first-set tiebreak win in just under an hour.
The setback woke Federer up, as he cut his unforced errors to four and broke the Russian in the eighth game to claim the second set before a break in the seventh game of the third saw him home to lift the trophy for a sixth time.
The wins sets Federer up nicely for his title defence at Wimbledon, and he said: "I'm very happy. It was a great week for me and my family.
"I thought I played well from the start and I really had to fight for it, in the semis against Tommy Haas and in the finals against Mikhail Youzhny.
"I think I did well today and they are exactly the kind of wins I need at this part of the season. I've been preparing well for this part of the season and I'm happy it's paying off. It's obviously important for my confidence looking forward to Wimbledon now.
"There's always pressure because it's a privilege to play at Wimbledon and I want to do so, so well. I feel good right now and I hope I can show it on the tennis court."
Youzhny acknowledged he had been beaten by the better man on the day.
"It was a good match for me," said the Russian. "I played good, but Roger was better today [Sunday]. It was a good tournament for me. I'm happy because I played a lot of matches at the same high level from the first point until the last point."