Defending champion Roger Federer rallied from a set and a break down to beat Ernests Gulbis 3-6, 6-1, 6-4 Friday and secure a place in the Madrid Masters semifinals. Federer lost to Gulbis last month at the Rome Masters in his first clay-court match of the season, and the Latvian looked set to repeat the upset until the top-ranked Swiss found his stride in the second set. Gulbis took a 3-0 lead in the first by converting his first break point when the onrushing Federer failed to return a ball driven at his feet. Federer then saved three set points before the Latvian converted his fourth with an ace, and continued by breaking Federer again to start the second. But it was all Federer from there, as he broke back immediately when Gulbis sent a forehand long and then dominated the rest of the set - despite having to save three break points himself at 3-1. In the decider, Federer used a perfectly judged backhand lob to break for a 2-1 lead, and was never threatened on his serve the rest of the way. He converted his first match point with a forehand winner, shortly after a light rain started falling over the court. Federer will next play third seed Andy Murray or ninth-seeded Spaniard David Ferrer in the semis. Earlier Friday, Rafael Nadal was close to his clay-court best in beating Gael Monfils 6-1, 6-3. The 23-year-old Monfils was playing his first clay tournament of the season and was outclassed by a dominant Nadal, who has not lost a service game in his three matches in Madrid. The second-seeded Spaniard pressured Monfils' serve from the start, and broke to go up 3-1 in the first set after the 12-seeded Frenchman double-faulted. Another unforced error by Monfils gave Nadal a second break, before he comfortably served out the set. Monfils earned his only two break points of the match when leading 2-1 in the second, but Nadal won the next four points and cruised through the rest of the set. Nadal is undefeated on clay this season with a 13-0 record, having won titles in Monte Carlo and Rome and is looking for a record 18th Masters title. Nadal and Andre Agassi have won 17 each, with Federer on 16. Nadal will play fellow Spaniard Nicolas Almagro, who beat Jurgen Melzer 6-3, 6-1 in the only quarterfinal not to feature a seeded player. Almagro broke Melzer twice to close out the first set before racing to a 3-0 lead in the second with some solid serving. The 24-year-old had another break before securing his first ATP Masters semifinal spot. Fourth-seeded Venus Williams reached the semifinals, beating Samantha Stosur 6-3, 6-3. In a strong performance Venus broke the eighth-seeded Stosur's serve four times. Venus, who will climb to the second ranking behind sister Serena next week, has now won all four of her meetings with the Australian. Venus will play Shahar Peer of Israel, who beat Li Na of China 6-4, 3-6, 6-4. Earlier, Lucie Safarova progressed to the semifinals with a 6-1, 1-6, 6-4 victory over 16th-seeded Nadia Petrova. Safarova will next face Aravane Rezai, who beat seventh-seeded Jelena Jankovic 7-5, 6-4.