Since wireless sensor networks are usually used for long-term monitoring in harsh environments, sensor nodes are vulnerable to faults. Function fault can lead to immediate node breakdown, while data fault makes the node generate erroneous sensor data. Faulty data results in incorrect estimation of the environment and causes unnecessary consumption of the network resources. Therefore, it is necessary to detect faulty data in real time. In this paper, a new distributed fault detection algorithm is proposed, which is based on the temporal and spatial correlation of the sensor data. With the proposed algorithm, faulty data is detected and discarded locally, so that the network resource consumption is minimized and the processing burden of the terminal is reduced. Simulation results show that the proposed algorithm improves detection accuracy, as compared to the baseline distributed fault detection algorithms.