In this paper, an energy management system (EMS) is proposed for optimal operation of a microgrid (MG). Dispersed photovoltaic arrays (PVs) and wind turbine generators (WTs) as renewable energy sources (RES) supply a major part of the network demanded energy. Also, an energy storage system (ESS), a micro-turbine unit (MT), and a fuel cell unit (FC) are integrated. The uncertainty and stochastic nature of the network load and RES data are treated via probabilistic modeling and scenarioselection approach. The predicted day-ahead data of the most diverse hourly scenarios are entered into the proposed EMS to determine the active and reactive power (P-Q) participations of local distributed resources. Likewise, it specifies the discharging/charging power and state of the ESS in addition to the exchanged active/reactive power amounts with the main network. The main goal is to maximize the profit of the secondary grid while satisfying all technical constraints. In the proposed EMS, the day-ahead energy management is developed as a comprehensive optimization problem. Moreover, the paper proposes novel modifications to improve the BAT optimization technique. The optimization problem of the energy management in the microgrid is implemented using a new integrated rule base-improved BAT method. Furthermore, the proposed EMS competence is proven by comparing its performance to recent literature.