The invention relates to a power optimal control method for a variable-speed and variable-pitch wind turbine. The variable-speed and variable-pitch wind turbine is controlled within the whole designed wind speed range. When the wind turbine operates between the cut-in wind speed and rated wind speed, a variable-speed control mode is adopted, and at the time, by adjusting the electromagnetic torque of a generator, the wind turbine is made to operate under the optimal efficiency CP max. When the wind turbine operates above the rated wind speed, a variable-pitch controller begins to be used, and by adjusting the pitch angle, the maximum power output is limited at a rated value. At the time, a torque controller is a variable-gain controller, and different gains are set according to the rotation speed values corresponding to different wind conditions. The phenomenon that the wind turbine generates high power output within a short time when affected by gust and the like is greatly relieved. In addition, a switch rule is set for the variable-pitch controller near the rated wind, so that frequent switching of the variable-pitch controller near the rated wind is avoided. By means of the power optimal control method for the variable-speed and variable-pitch wind turbine, the service life of a gearbox is prolonged, and it is guaranteed that the wind turbine operates in a bad environment.