In this paper, a recent metaheuristic approach of sparrow search algorithm (SSA) is employed to manage the operation of microgrid (MG) in an optimal manner. Two optimization problems are formulated in this work, the first one is a single objective problem that aims at minimizing either the total operating cost or the total emission from the system. The second problem is multi-objective comprising both total operating cost and total emission simultaneously. A new version of SSA is proposed to manage the energy of MG optimally. The considered MG comprises photovoltaic modules (PV), wind turbine (WT), fuel cell (FC), micro-turbine (MT), batteries (BSS), and grid. The obtained results using the proposed SSA are compared to other programmed approaches of krill herd optimizer (KH), Harris hawks optimizer (HHO), artificial ecosystem-based optimizer (AEO), Fuzzy-self adaptive particle swarm optimization (FSAPSO), and antlion optimizer (ALO). Non-parametric analysis using Friedman and Kruskal–Wallis ANOVA tests are applied for evaluating the proposed algorithm performance statistically. At solving the single objective problem, the proposed SSA achieved minimizing in cost and emission with 1.44% and 54.76% respectively compared to KH. Regarding the multi-objective problem, the proposed multi-objective SSA (MOSSA) succeeded in saving about 42.78% in operating cost and reducing the emission by 0.118% compared to ALO. The main findings demonstrated the robustness of the proposed SSA in managing the operation of the constructed MG.