The electric train (ET) is a great energy consumer in an electrical network, which regenerates a high amount of energy into the grid at the braking moment. Therefore, in this paper, the optimal operation of the electric railway system is proposed considering renewable sources, hybrid storage systems (battery and ultracapacitor units), switchable capacitor banks, and regenerative braking energy of ET at the same time to attain a favorable economic, environmental and operational condition. Renewable sources reduce operating costs and environmental pollution. The storage system is utilized as a flexible source along with renewable generations. The ultracapacitor stores the ET braking energy, and the capacitor bank regulates the voltage. The scheme minimizes the expected network operating cost, while the AC optimal power flow and other technical limits are considered. This problem is nonlinear, and a linearized approximation formulation is implemented to achieve a unique optimal solution with the best and minimum computation time. The unscented transformation method is used to model uncertainties of load, ETs’ energy consumption, and renewable energies. Finally, by evaluating the numerical results, it is illustrated that the efficiency of the proposed method simultaneously improves the economic, environmental, and operational features of the network.