Top seed Rafael Nadal was sent crashing out of the Shanghai Masters on a dramatic day of action on Thursday but defending champion Andy Murray survived a testing encounter to reach the quarter-finals. World number two Nadal lost 6-7 (5/7), 3-6 to Germany's Florian Mayer, edged out in a first set tiebreak and broken twice in the second set, stunning the crowd at the Qi Zhong stadium. Mayer made the crucial breakthrough in the seventh game of the second set to lead 4-3 and the Spaniard could not respond, broken again in the final game with the 15th seed taking his first match point. "He played really well, I didn't," said Nadal. "I felt that I was not playing badly from the baseline. But my return, when he was serving the first serve, was terrible tonight. I only won four points in the whole match on his first serve." "For me today is a disappointing day. I felt that I did everything right. I was in the right line since the week before the US Open," added Nadal, who lost in the final at Flushing Meadows to Novak Djokovic. Mayer, who won his first tour title in Bucharest last month, said after the third round match: "It's a really nice feeling. He's such a great competitor on court. Yeah, for sure it is the biggest win in my career." Earlier, second seed Murray, on a red-hot run of form of 21 wins from 22 matches coming into the clash against the Swiss 13th seed Stanislas Wawrinka, won 6-4, 3-6, 6-3. The British player looked set for a straightforward victory after taking the first set but cut a frustrated figure as he conceded a break of serve in the second set as Wawrinka levelled the match with an ace. Murray raced into a 5-0 lead in the decider as Wawrinka was warned by the umpire after smashing his racket, but despite a late wobble he closed out the match. "I got myself pumped up right at the beginning of the third set. I think it was important," said Murray. "Stan was playing very well. I was trying to control the ball." Spain's Ferrer edged into the last eight when he beat Juan Carlos Ferrero, who had strapping applied to his right ankle midway through the second set. Third seed Ferrer won the all-Spanish tie 1-6, 7-5, 6-2 after a major fright in the 10th game of the second set, when he was forced to save three match points on his own serve. The win for Ferrer means he becomes the fifth player to qualify for the season-ending ATP World Tour Finals, featuring the world's top eight singles players over the year. American 10th seed Andy Roddick beat Spanish seventh seed Nicolas Almagro 6-3, 6-4 and Ukrainian 12th seed Alexandr Dolgopolov won 5-7, 6-1, 6-0 against Australian teenager Bernard Tomic. Japan's Kei Nishikori triumphed over Santiago Giraldo of Colombia 7-6 (8/6), 4-6, 6-3 and Australia's Matthew Ebden beat eighth seed Gilles Simon of France 6-2, 2-6, 7-6 (10/8). In the late match, Spain's Feliciano Lopez beat sixth seed Tomas Berdych of the Czech Republic 6-4, 6-4.