The Swiss won 6-7(3), 6-4, 6-1 to claim a second victory on his debut appearance at the year-ending event although should Tomas Berdych beat already-qualified Nadal later on Friday it will prove to be the last match of Wawrinka's season.
Round-robin tennis causes plenty of head scratching but for Berdych the scenario is quite simple, a straight sets win over the world No.1 means he wins Group A, a three-sets win and he qualifies as runner-up.
Defeat would send him home to concentrate on the Davis Cup final against Serbia in Belgrade.
Neutrals will hope that Wawrinka does survive because his exciting brand of tennis has illuminated the tournament so far.
His chances seemed to be slipping away on Friday when he squandered a 5-2 lead in the first set and allowed Ferrer to take it on a tiebreak.
Wawrinka, who is pushing fellow Swiss Roger Federer in the rankings after the most consistent year of his career, aced his way out of trouble early in the second before taking over.
Ferrer, labouring after seven tournaments in seven weeks leading into London, lost his cool in the next game, destroying his racket and scolding himself after dropping serve.
Having won the second set, Wawrinka raced through the third for victory.
"For sure, I'm going to be a big fan of Rafa (tonight)," Wawrinka said on court. "I did my job all week. I did the best I can so now I'm just going to watch what is going to happen. I'll be really happy if Rafa wins."
Nadal knows losing to Czech Berdych would put him on collision course with Novak Djokovic in the semi-finals.
Image: Stanislas Wawrinka
Photograph: Julian Finney/Getty Images
Beaten Wawrinka digs into Nadal for receiving tips on court
World Tour Finals: Wawrinka, Del Potro give taste of things to come
Nadal fends off Wawrinka to seal year end top ranking
Djokovic douses Federer's fire, Nadal crushes Ferrer
Tour Finals: Djokovic fends off Del Potro, hope for Federer