BERN, Switzerland (AP) Roger Federer overcame early problems to beat Portugal's Rui Machado and give Switzerland a 2-0 lead in the Davis Cup on Friday.

Federer's service was broken twice in the opening set by the 93rd-ranked Machado before he recovered to win 5-7, 6-3, 6-4, 6-2 in the Group I second-round match.

Federer was playing his first match since losing in the Wimbledon quarterfinals to Jo-Wilfried Tsonga last week.

Federer's Olympic gold medal-winning doubles partner Stanislas Wawrinka defeated Frederico Gil 7-5, 6-3, 6-4.

Federer and Wawrinka are scheduled to face Gil and Leonardo Tavares in doubles on Saturday. The contest is being played on indoor hard courts in Bern, Switzerland.

The winning nation advances to a playoff in September to join the 16-nation world group.