Node localization is one of the key technologies of WSN applications. In this paper, we propose a distributed weighted search-based localization algorithm (WSLA) and its refinement algorithm (WSRA) for wireless sensor network (WSN). In real applications, WSLA + WSRA need to run iteratively to achieve localization and position refinement of nodes. In each iteration of WSLA, every node obtains the coordinate and distance information of its 1-hop neighbors, and then employs weighted two-dimensional logarithmic search to compute its best estimated position; finally, every node estimates its coordinate and type according to the distribution of its best estimated positions. By analyzing experiment results of WSLA, we found some errors, and eventually propose WSRA that is based on geometrical relationship of neighbors. Finally, we compare the localization performance and complexity of WSLA + WSRA with those of MLE, RSOCP + NCSG and PSO, which are three state-of-the-art range-based localization algorithms, in different network scenarios (e.g., uniform topology, irregular C-shaped network and fading environment). The simulation results show that WSLA + WSRA have relatively high localization accuracy and low computational complexity compared with MLE, RSOCP + NCSG and PSO.