This paper proposes a nested-loop extremum seeking control (NLESC) scheme for optimizing the energy capture of wind farm that is formed by a wind turbine array along the prevailing wind direction. It has been shown in earlier work that the axial induction factors of individual wind turbines can be optimized from downstream to upstream units in a sequential manner, which is a spatial domain analogy to the principle of optimality in dynamic programing. Therefore, it is proposed to optimize the turbine operation by a nested-loop optimization framework from the downstream to upstream turbines, based on feedback of the power of the immediate turbine and its downstream units. The extremum seeking control (ESC) based on dither–demodulation scheme is selected as a model-free real-time optimization solution for the individual loops. First, the principle of optimality for optimizing wind farm energy capture is proved for the cascaded wind turbine array based on the disk model. Analysis shows that the optimal torque gain of each turbine in a cascade of turbines is invariant with wind speed if the wind direction does not change. Then, the NLESC scheme is proposed, with the array power coefficient selected as the performance index to be optimized in real-time. As changes of upstream turbine operation affect downstream turbines with significant delays due to wind propagation, a cross-covariance based delay estimate is used to improve the determination of the array power coefficient. The proposed scheme is evaluated with simulation study using a three-turbine wind farm with the simwindfarm simulation platform. Simulation study is performed under both smooth and turbulent winds, and the results indicate the convergence to the actual optimum. Also, simulation under different wind speeds supports the earlier analysis results that the optimal torque gains of the cascaded turbines are invariant to wind speed.