The Swiss, who has won the German title seven times, needed two tie-breaks to claim a 13th win in 14 meetings with Karlovic.
The Croat, who stands 6ft 11in tall, had battered down 45 aces in his quarter-final victory against Czech Tomas Berdych on Friday – eclipsing the previous ATP three-set record – but here he managed a mere 21.
Both players held serve until Federer made a mini-break to go 4-3 up in the first tie-breaker; the world No 2 did not waste the opening, taking the first set on Karlovic’s double-fault.
Federer saved the only break point he faced at 2-1 in the second before – after another attritional set a mini-break put Federer 3-2 up in the second tie-break, but Karlovic responded for 3-3.??
The seven-time Wimbledon champion correctly challenged a call that would have put the eighth-seeded Croat in front and secured another mini-break when Karlovic hit a return to the net; Federer wrapped it up in 88 minutes.
Federer is chasing a 15th title on grass as he warms up for Wimbledon, which begins on June 29.