Rafael Nadal kept his hopes of a last-four place at the ATP Finals alive with a sensational 6-7 6-4 7-5 victory over Stefanos Tsitsipas.