Localization is an essential issue in wireless sensor networks because many applications require the sensor nodes to know their locations with a high degree of precision. Various localization methods based on mobile anchor nodes have been proposed for assisting the sensor nodes to determine their locations. However, none of these methods attempt to optimize the trajectory of the mobile anchor node. Accordingly, this paper presents a path planning scheme, which ensures that the trajectory of the mobile anchor node minimizes the localization error and guarantees that all of the sensor nodes can determine their locations. The obstacle-resistant trajectory is also proposed to handle the obstacles in the sensing field. The performance of the proposed scheme is evaluated through a series of simulations with the ns-2 network simulator. The results show that the proposed path planning algorithm yields both a lower localization error and a higher percentage of localized sensor nodes than existing path planning schemes.