Context: The use of capacitor banks is the most common and preferred solution for reducing power loss in electrical distribution networks, given their cost-effectiveness and low maintenance requirements. However, achieving their optimal integration in terms of location and size is a challenging problem. Method: This paper proposes a stochastic mixed-integer convex model based on a branch flow optimization model, which incorporates three different load-generation conditions, in order to address the stochastic nature of distribution systems.Results: The simulation results indicated that the proposed stochastic mixed-integer branch flow (SMIBF) model provides the best solution for all test feeders analyzed, reducing the objective function value by 39.81%, 35.29%, and 56.31% for the modified 33-, 69-, and 85-node test feeders, respectively.Conclusions: An SMIBF model was developed to optimally integrate fixed-step capacitor banks into electrical distribution grids. This model considered the stochastic nature of distribution systems under multiple operating conditions and ensured that the global optimum could be found.