This paper presents a distributed strategy for the optimal dispatch of islanded microgrids, modeled as unbalanced three-phase electrical distribution systems (EDS). To set the dispatch of the distributed generation (DG) units, an optimal generation problem is stated and solved distributively based on primal-dual constrained decomposition and a first-order consensus protocol, where units can communicate only with their neighbors. Thus, convergence is guaranteed under the common convexity assumptions. The islanded microgrid operates with the standard hierarchical control scheme, where two control modes are considered for the DG units: a voltage control mode (VCM), with an active droop control loop, and a power control mode (PCM), which allows setting the output power in advance. To assess the effectiveness and flexibility of the proposed approach, simulations were performed in a 25-bus unbalanced three-phase microgrid. According to the obtained results, the proposed strategy achieves a lower cost solution when compared with a centralized approach based on a static droop framework, with a considerable reduction on the communication system complexity. Additionally, it corrects the mismatch between generation and consumption even during the execution of the optimization process, responding to changes in the load consumption, renewable generation and unexpected faults in units.