Homing operation can be defined as a series of actions which are necessary for a mobile robot to move from the current position with any arbitrary orientation to a desired position with a specified orientation, while avoiding possible obstacles. In this paper, a homing and obstacle avoidance algorithm for nonholonomic mobile robots is proposed. The proposed algorithm consists of a local goal generator, a discrete state controller, and local path tracking controller based on Aicardi's path following algorithm. In the discrete state controller, 4 states are defined according to the environmental conditions and 4 desired high-level command for the states are given as follows: avoid, wander, home and homing zones. The proposed local goal generator is designed to generate the desired local path by using weighted distance transforms which are newly made to satisfy the nonholonomic constraints of mobile robots. Here, subgoals are also found as vertices of the desired local path. To demonstrate result effectiveness and applicability of the proposed algorithm, computer simulations are illustrated and experimental results for a real mobile robot system are also provided.