In this paper, an optimal distributed approach is presented to solve the economic dispatch (ED) problem in an islanded microgrid. Active and reactive resources are taken into account in the optimization problem aiming to consider the operational requirements of the electrical system. The optimization framework is based on primal-dual constrained decomposition. Additionally, two consensus algorithms are develop to be executed in parallel by each unit, aiming to estimate locally the value of the dual variables. Convergence is guaranteed under the common convexity assumptions. Simulations were performed on the standard IEEE 30-bus system considering dispatchable and renewable generation units. The capability of the algorithm to responds in variations in load consumption, renewable generation and faults in units were assessed. Result shows the flexibility and effectiveness of the proposed approach.