The former world number one lost the first set to his Tunisian opponent 7-5, before going on to win through thanks to a 6-0 6-2 success.
Reflecting on the three-set win, Federer admitted that he had found it "difficult" to overcome a player who is ranked 128 in the latest standings.
"It important to sort of react and make sure I didn't panic," said Federer. "But, of course your mind starts to wander, especially in a match where there is hardly any rallies. He's going for broke on every return. All you're trying to do is get into some rallies, and you're missing a lot yourself.
"It was a difficult match for me out here tonight, but I'm happy I found a way and got a day off now so I can work a little bit on the game. Just maybe the pressure is off a little bit, and then automatically I will play a lot better in the second round."
The match was Federer's first on the ATP circuit since October 2012.