Federer, 32, largely dominated the 62nd ranked player in the world in a match that was originally scheduled to be played on Monday but was postponed because of rain.
The Basel native, now ranked seventh in the world after a disappointing showing this season, remains in the running for his first major title this year.
The 17-time Grand Slam winner beat 26-year-old Zemlja 6-3, 6-2, 7-5 in 93 minutes to advance in the New York tournament he has won five times.
"You're going to have some hiccups like I had today. " Federer said.
“It was a minor one,” he said.
"There wasn't much rhythm out there, but I was happy the way I played," said Federer.
"Overall I'm pleased to be in the next round."
In the second round he faces Carlos Berlocq, a 30-year-old Argentinian who is ranked 48th in the world, putting him on a quarter-final collision course with second seed Rafael Nadal, whom he has never faced at the US Open.
Federer, whose 56th Grand Slam start in a row matched South African Wayne Ferreira for the all-time record run, has only one title in his past 14 Slam starts, that coming last year at Wimbledon.
The Swiss won five US Open titles in a row from 2004 to 2008.
In other action in New York, top-ranked Novak Djokovic launched his quest for a fourth consecutive US Open final by beating Lithuanian 112th-ranked Ricardas Berankis 6-1, 6-2, 6-2.
Djokovic fired 10 aces and 28 winners and needed only 82 minutes to put himself into a last-64 matchup against Germany's Benjamin Becker.