After securing a record-equalling seventh Wimbledon title earlier this month, Federer is desperate to complete a career Golden Slam by winning a singles gold medal for the first time.
The 17-time Grand Slam champion, who won doubles gold with compatriot Stanislas Wawrinka in Beijing in 2008, was slightly below his best against Istomin, but even at less than 100 percent Federer was still too good for the world number 34 in a rain interrupted clash at Wimbledon.
Federer, 30, will play Serbian seventh seed Janko Tipsarevic or American John Isner for a place in the semi-finals.
After a rain delay of over an hour, Federer finally made it onto Court One and the Swiss star looked set for a routine win when he broke in the second game of the match.
But a commanding 3-0 lead for Federer swiftly disappeared as Istomin broke back and began to hammer down some powerful serves.
Istomin, who became the first player from Uzbekistan to reach the fourth round of a Grand Slam at Wimbledon last month, was beginning to cause Federer some serious problems when rain forced a stoppage.
Federer had to save two break points when they returned at 5-5 half an hour later and he made the most of that escape by converting his third set point in the next game.
That signalled a resumption of normal service after Federer’s brief wobble and a break in the second game of the second set was enough to get the Swiss great to the finish line.