Federer lost the first set Tuesday after having his service broken in the ninth game, then had to save three set points against Andreev's serve in the 12th game of the third set before winning it in a tiebreaker.
He dominated the fourth, ensuring there was no similar end to his previous match at Rod Laver Arena -- he finished in tears last year after losing the final to Rafael Nadal.
"I hoped I was going to hang in there, that he was going to get tired. It was a tough first round. I'm really, really relieved," Federer said. "I think I definitely got lucky to get out of that one. It was a fortunate third set today."
Federer hasn't lost the opening round since the 2003 French Open, the event before he won Wimbledon for the first of his 15 Grand Slam titles.
On Tuesday, he was all smiles at the courtside television interview with two-time Australian Open champion and now commentator Jim Courier, who reminded Federer that he had not lost a set in the first round of a major in more than six years.
"I did know it was going to be tough, we played five sets in New York two years back and I really had to adjust my game to beat him," Federer said of Andreev. "... I prefer easier matches, but this worked as well."
In other matches, third-seeded Novak Djokovic beat Daniel Gimeno-Traver of Spain 7-5, 6-3, 6-2 in a night match. Djokovic won his first and only Grand Slam at the 2008 Australian Open, losing only one set during the two-week tournament and beating Federer in the semifinals.
Hometown favorite Lleyton Hewitt, still trying to win his first Australian Open after losing in the 2005 final to Marat Safin, opened with a 6-1, 6-2, 6-3 win over qualifier Ricardo Hocevar of Brazil.
Sixth-seeded Nikolay Davydenko, No. 9 Fernando Verdasco -- who lost an epic five-set semifinal to Nadal here last year -- No. 10 Jo-Wilfried Tsonga of France, No. 12 Gael Monfils of France, No. 19 Stanislas Wawrinka of Switzerland and No. 21 Tomas Berdych of the Czech Republic all advanced.
Americans James Blake and John Isner reached the second round, but No. 25 Sam Querrey lost to German veteran Rainer Schuettler. Blake posted a 7-5, 7-5, 6-2 victory over Frenchman Arnaud Clement, while Isner held off Andreas Seppi of Italy 6-3, 6-3, 3-6, 5-7, 6-4.
The 37-year-old Frenchman, who started his Grand Slam career at the 1989 French Open, retired last season but returned to Melbourne Park for a record 70th major.
The rain that allowed only 26 of the scheduled 64 matches to be completed on the opening day gave way to sunny conditions by Tuesday afternoon.
Information from The Associated Press was used in this report.