Several studies have been reported for optimal operation of electrical railway systems (ERSs). However, the stochastic energy management of ERSs, including renewable energy resources (RERs), has received less attention. The RERs’ uncertainties might affect the ERSs. On the other hand, the calculation time of the Monte Carlo simulation (MCS)‐based approaches is an essential challenge, which should be solved, particularly in real‐time decisions and recursive optimization problems. Thus, it is crucial to study the ERSs' stochastic behaviors and uncertainties, including RERs. This paper tries to overcome the discussed concerns and challenges by proposing a novel ERS’s optimal stochastic energy management using clustering algorithms. In this paper, the backward scenario reduction algorithm has been used. In addition, regenerative braking energy (RBE) and energy management systems (ESSs) have been studied. Studying the impacts of changes in the number of passengers on the optimized operation of ERSs and investigating the interaction between the utility grid and the ERS are other contributions of this research. The proposed method is applied to an actual test system of Tehran Urban and Suburban Railway Operation Company (TUSROC). Test results are validated by comparing with available MCS‐based methods. Simulation results illustrate the accuracy and computation time advantages of the proposed method. Simulation results illustrate that <0.6% inaccuracy appears in the proposed method, while it would be 500 times faster than MCS‐based ones. The comparative test results show the advantages of the introduced method.