The optimal location and setting of the unified power flow controller (UPFC) along with power plant generators' output parameters to enhance power systems reliability in the presence of uncertain variables are determined in this paper. For this purpose, the expected power not served (EPNS) is used as a reliability index based on the total required load shedding at all buses in case of single contingencies such as the outage of lines or generators. The EPNS and components of system's normal operating conditions such as active power losses, voltage deviation index (VDI), as well as economic components, namely, the cost of power generation and UPFC allocation, are taken into consideration in the objective function. The particle swarm optimization (PSO) algorithm optimizes this objective function. Afterward, the firefly algorithm (FA) determines the minimum quantity of required load shedding based on all possible solutions obtained by PSO. Because of the probabilistic nature of loads and renewable generations like wind power generation (WPG), an accurate probabilistic assessment is essential. Therefore, the two‐point estimate method (2PEM) is used, and its performance is compared with the Latin hypercube sampling (LHS) method. The proposed solution method is evaluated on the IEEE 14‐bus and the IEEE 57‐bus test systems and results are discussed.