Murray, ranked 11th, had little trouble in the first set and looked poised for a quarter-finals berth, but Ferrer staged a brilliant comeback, breaking the Briton twice to take the second and level the match.
There was no let up in the final set either as the Spaniard raced to a 5-2 lead and raised his arms in celebration when Murray buried a return into the net.
With the win, Ferrer replaces Murray in ninth spot in the race for the eight-man Tour Finals.
Czech Tomas Berdych also boosted his hopes of securing one of the five remaining places in London with a 6-3 6-4 victory over Ivo Karlovic, who hit 19 aces in the third-round clash.
Berdych will replace U.S. Open champion Marin Cilic, beaten by Karlovic in the opening round in Shanghai, in sixth place in the race to London if he beats Gilles Simon in the quarter-finals on Friday.
Frenchman Simon overcame Malek Jaziri of Tunisia 6-2 6-3 while Julien Benneteau beat American Jack Sock 6-3 6-4. – Reuters