In this paper, a safe map building and area search algorithm for a mobile robot in a closed unknown environment with obstacles is presented. A range finder sensor is used to detect the environment. The objective is to perform a complete search of the environment and build a complete map of it while avoiding collision with the obstacles. The developed robot navigation algorithm is randomized. It is proved that with probability 1 the robot completes its task in a finite time. Computer simulations and experiments with a real Pioneer-3DX robot confirm the performance of the proposed method.