In this paper, dynamically balanced gait generation problem of a 7-DOF two-legged robot moving up and down through the sloping surface is presented. The gait of the lower links during locomotion is obtained after assuming suitable trajectories for the swing leg and hip joint. The trunk motion is initially generated based on the concept of static balance, which is different from the well-known semi-inverse method and then checked for its dynamic balance calculated using the concept of Zero-Moment Point (ZMP). Lagrange–Euler formulation is attempted for the determination of joint torques. Average power consumption at each joint is then determined based on the computed torques. Moreover, the variations of dynamic balance margin and average power consumption are studied for both ascending and descending through the sloping surface. Both of them are found to be more for the ascending gait generation compared to those for the descending case. The effects of variations of the slope have also been studied on the average dynamic balance margin and power consumption for both the cases.