The Swiss number one took a while to get into his stride, as the Slovenian stuck with him until the decisive breakthrough came, with Federer taking a 5-3 lead and serving out.
Federer then broke at the first time of asking in the second set, before securing the double to go 5-2 ahead and eventually sealing it 6-2.
The 32-year-old struggled to break Zemelja once again in the third set, but managed to do so for a 4-3 lead on serve. However, Zemelja then broke back to restore some pride.
That did not stop Federer from wrapping up the final set 7-5, which sees him book a clash with Carlos Berlocq in the next round.