Accuracy is still the greatest challenge in the wireless sensor network localization efforts. Several diverse factors can give rise to localization errors. Modeling such diverse influencing factors to deliver a single, reasonably simple and practical solution is a difficult task. In order to address the problem of location inaccuracy, we propose a comparatively simple and ingenious approach, which is the simultaneous perturbation stochastic approximation (SPSA) localization engine. SPSA bypasses tedious modeling of the influencing factors where some of them are yet to be explored and random in nature. SPSA-based localization estimates the non-anchor node locations through minimizing the summation of estimated errors of all neighbors. However, the downside of SPSA is that it incurs errors in some specific relative neighborhood configurations often referred to as flip ambiguity. So, we further propose a solution to the flip ambiguity problem by implementing a constrained optimization with a penalty function method on the identified flip nodes. Most importantly, error propagation of the iterative localization algorithm is managed by incorporating a neighbor confidence matrix. We name this modified SPSA engine as simultaneous perturbation stochastic approximation by neighbor confidence (SPSA-NC). Experimental results show that SPSA-NC offers significantly better localization accuracy than its state-of-the-art competitors, namely, simulated annealing and the ordinary SPSA. The SPSA-NC program is available for downloading at http://www.dnagroup. org/SPSANC.