The 39-year-old Swiss had not played a competitive match for more than a year having undergone two knee surgeries last year.
Federer beat British number one Dan Evans 7-6, 3-6 7-5.