This research introduces a pioneering Energy Management System (EMS) for microgrids, integrating fuzzy neural networks and a modified particle swarm optimization (MPSO) algorithm. The key contribution lies in minimizing production costs while optimizing the use of renewable sources like photovoltaic (PV), wind turbines (WT), and energy storage. The novel approach considers time-dependent constraints, ensuring adaptability and superior system performance. Additionally, the study introduces an innovative demand response (DR) analysis using a neural-fuzzy network, enhancing customer response and energy cost dynamics. The MPSO algorithm addresses economic load distribution challenges, demonstrating superior performance in comparative analysis. This integrated approach offers a groundbreaking solution for sustainable and efficient energy planning in microgrids. The analysis demonstrates that the proposed method achieves higher energy savings (83%) compared to baseline levels of 72%, showcasing its superior efficiency. Comparative analysis with genetic and particle swarm optimization algorithms reveals consistently lower average expenses and increased cost-effectiveness with the proposed approach.