Due to rising global energy demand and mounting environmental concerns associated with the widespread use of fossil fuels in conventional power plants, it is imperative that viable and cleaner energy sources are used. Here, virtually pollution-free renewable energy sources have replaced traditional fossil fuels as the go-to option for meeting the rising energy demand. This research article utilizes a new formulation for minimizing the total cost of a microgrid through a short-term operational strategy. Microgrids and demand-side management can improve the distribution network’s efficiency and reliability. To achieve this goal, this paper explores how to best schedule the uncertain operation of a microgrid including both renewable energy resources like wind turbines and photovoltaics, as well as dispatchable resources like fuel cells, microturbines, and electrical storage devices connected to charging stations for electric vehicles. Considering the unpredictability of wind power and solar power outputs, besides the behavior of plug-in electric vehicle owners in terms of plugging into the grid to inject or receive power, a stochastic programming-based framework is introduced for the operation of microgrids running in the grid-integrated mode. In this study, an innovative and effective optimization algorithm is employed, which is the modified manta ray foraging optimization algorithm, as a high-efficiency method for maximizing the microgrid efficiency. After applying the proposed method to a standard microgrid, the simulation results show how effective it is compared with other approaches.