Escalating energy demands and climate change challenges necessitate the adaptation of renewable-based microgrid systems in the energy sector. The proposed work employs a robust Multi Agent System (MAS) technique to achieve efficient and automated control of the hybrid microgrid operation. The hybrid microgrid system incorporates Renewable Energy Sources (RES), a diesel generator, and a battery storage system. The operation of the hybrid microgrid consists of three distinct modes: islanded, transition to grid, and grid-oriented mode. The system's performance is optimized by considering factors like climatic patterns, energy costs, connected source characteristics, and load demand. Different climatic scenarios are assessed for each mode of operation, where the best, extreme sunny, extreme cloudy, and worst climate conditions are considered for islanded mode; sunny and cloudy scenarios are considered for transition to grid mode as well as grid-feed and grid-tied modes are considered for grid-oriented operation of the microgrid. The simulation studies are performed using the MATLAB/Simulink R2021a environment. Furthermore, Particle Swarm Optimization (PSO) is implemented to optimize power allocation within the microgrid and enhance its cost-effectiveness. The optimization results demonstrate efficient utilization of available energy sources along with effective energy management facilitated by the MAS control system. The results emphasize the importance of adopting a MAS approach for achieving smart energy management through comprehensive analysis and integrating decentralized energy management techniques for optimal accommodation of distributed energy resources in hybrid microgrids.INDEX TERMS Renewable energy sources, particle swarm optimization, energy management system, multi agent system, microgrid. NOMENCLATURE RES Renewable energy sources. DER Distributed energy resources. PV Photovoltaic. MAS Multi agent system. PSO Particle swarm optimization. AI Artificial intelligence. MILP Mixed integer linear programming.The associate editor coordinating the review of this manuscript and approving it for publication was Xiwang Dong.