To mitigate the impacts of non-line-of-sight(NLOS) errors on location accuracy, a non-parametric belief propagation(NBP)-based localization algorithm in the NLOS environment for wireless sensor networks is proposed.According to the amount of prior information known about the probabilities and distribution parameters of the NLOS error distribution, three different cases of the maximum a posterior(MAP) localization problems are introduced. The first case is the idealized case, i. e., the range measurements in the NLOS conditions and the corresponding distribution parameters of the NLOS errors are known. The probability of a communication of a pair of nodes in the NLOS conditions and the corresponding distribution parameters of the NLOS errors are known in the second case. The third case is the worst case, in which only knowledge about noise measurement power is obtained. The proposed algorithm is compared with the maximum likelihood-simulated annealing(ML-SA)-based localization algorithm. Simulation results demonstrate that the proposed algorithm provides good location accuracy and considerably outperforms the ML-SA-based localization algorithm for every case. The root mean square error(RMSE)of the location estimate of the NBP-based localization algorithm is reduced by about 1. 6 m in Case 1, 1. 8 m in Case 2 and 2. 3 m in Case 3 compared with the ML-SA-based localization algorithm. Therefore, in the NLOS environments,the localization algorithms can obtain the location estimates with high accuracy by using the NBP method.