Recently, microgrids have attracted considerable attention as a high-quality and reliable source of electricity. In this work energy management in microgrids is addressed in light of economic and environmental restrictions through (a) development of an operational strategy for energy management in microgrids and (b) determination of type and capacity of distributed generation (DG) sources as well as the capacity of storage devices (SD) based on optimization. Net present value is used as an economic indicator for justification of investment in microgrids. The proposed NPV-based objective function accounts for the expenses including the initial investment costs, operational strategy costs, purchase of electricity from the utility, maintenance and operational costs, as well as revenues including those associated with reduction in non-delivered energy, the credit for reduction in levels of environmental pollution, and sales of electricity back to the utility. The optimal solution maximizing the objective function is obtained using a hybrid optimization method which combines the quadratic programming (QP) and the particle swarm optimization (PSO) algorithms to determine the optimum capacity of the sources as well as the appropriate operational strategy for the microgrid. The fuzzy set theory is employed to account for the uncertainties associated with electrical power price. Application of the proposed method under different operational scenarios serves to demonstrate the efficiency of the proposed scheme.