Recent research on mobile robots is focused on locomotion in various environments. In this paper gait generation algorithm for a mobile robot that can locomote from ground to wall and climb vertical surfaces is proposed bio-inspired by a gecko lizard. The gait planning is based on the inverse-kinematics with the Jacobian of whole body, where the redundancy is solved by defining an object function to follow the real gecko posture and avoid collisions with the surface. The optimal scalar factor for these two objects is obtained by defining a superior object function that is to minimize the angular acceleration. The algorithm was verified through simulation of the gecko model locomoting given task paths avoiding abnormal joint movements and collisions.