SHANGHAI — Roger Federer crashed out of the Shanghai Masters Thursday at the hands of flamboyant Frenchman Gael Monfils — unable to rekindle the magic that saw him dominate the sport for so many years. Monfils will play top seed and defending champion Novak Djokovic in the quarterfinals after the Serb defeated Fabio Fognini of Italy 6-3, 6-3. Top seed Rafael Nadal, chasing a record sixth Masters title in a single season, saw off Carlos Berlocq of Argentina 6-1, 7-6 (7-5). Monfils went into the match against the 17-time Grand Slam champion with just one victory in seven meetings with the Swiss. But he went toe-to-toe with Federer during a feast of attacking tennis, eventually winning 6-4, 6-7 (5-7), 6-3. Federer, playing his first tournament since the US Open, started in the worst possible way, limply losing his first service game to immediately hand the initiative to Monfils, who went on to take the opener. Despite vocal support from a partisan crowd, Federer was broken midway through the second set but he broke back straight away, sealing the game with an overhead smash. Monfils, clad in bright orange, drew first blood in the tie-break but crucially put a straightforward forehand long when he had a chance to engineer two match points, allowing Federer back into the set. With both players continuing to attack, Monfils grabbed the initiative, breaking to take a 3-1 lead and keeping his nerve to see out the match. The Frenchman, 27, admitted he had “choked” in the tie-break but said he had regrouped and tried to stay aggressive, which ultimately paid off. Despite the win, Monfils said the Swiss, who struck 32 winners but also 36 unforced errors, still inspired the fear factor in opponents. Elsewhere in third-round action, Germany's Florian Mayer, ranked 50th in the world, shocked Spanish third seed David Ferrer 6-4, 6-3. Seventh seed Jo-Wilfried Tsonga brushed aside Kei Nishikori 7-6 (7-5), 6-0 to reach the quarterfinals as Juan Martin del Potro progressed with a walkover after German veteran Tommy Haas withdrew from their match with a back injury. Stanislas Wawrinka of Switzerland beat Milos Raonic of Canada 7-6 (2), 6-4, while Almagro beat Czech fourth seed Tomas Berdych in three sets. Keys in quarterfinals In Osaka, sixth-seeded Madison Keys reached her fourth WTA quarterfinal of the season Thursday by beating China's Shuai Zhang 6-3, 6-0 in the second round of the Japan Open. The 18-year-old American won nine successive games to wrap up the match in just 51 minutes. Keys lost just three points in the second set. Ninth-seeded Kristina Mladenovic of France faltered after winning a 67-minute first set, losing 6-7 (5), 6-2, 6-0 to Jie Zheng of China. Jie will play Keys Friday for a place in the semifinals. Misaki Doi also reached the quarters by beating fellow Japanese player Kimiko Date-Krumm 7-6 (3), 6-4. Doi will face American Samantha Stosur, who at No. 3 is the highest seeded player still in the tournament. Cibulkova in quarters Dominika Cibulkova of Slovakia routed Katarzyna Piter of Poland 6-0, 6-1 in less than 53 minutes Thursday to reach the quarterfinals of the Generali Ladies. Cibulkova will take on two-time former champion Ana Ivanovic. Patricia Mayr-Achleitner of Austria defeated Maryna Zanevska of Ukraine 6-1, 6-7 (1), 6-4 and Stefanie Voegele of Switzerland rallied to defeat Karin Knapp of Italy 4-6, 6-2, 7-5 to make quarterfinals. Moya banking on Nadal Carlos Moya hopes his close relationship with Rafael Nadal will help convince him play for Spain's Davis Cup team. Moya was introduced Thursday as Spain's new Davis Cup captain, replacing Alex Corretja. Moya's first match in charge of the five-time champion will be the first-round World Group tie against Germany from Jan. 31-Feb. 2. The 37-year-old Moya, winner of the 1998 French Open, says his friendship with Nadal could sway his fellow Mallorcan to play against Germany. — Agencies