Microgrids with distributed energy generators, controllable appliances, electric vehicle charging infrastructures, and energy storage systems introduce new technical challenges in the management of distribution networks. This paper introduces a new framework for power flow control based on the emerging consensus control for networked systems. Due to unique features of power systems, the consensus control problem becomes weighted and constrained, beyond the typical consensus formulation. Using only neighborhood communication for each bus on the microgrid, the consensus control achieves global weighted load balancing. Algorithms are introduced and their convergence properties are established. It is shown that the algorithms have the fastest convergence rates in terms of consensus error variances, by achieving asymptotically the Cramér-Rao lower bound, and hence is optimal among all algorithms. Examples and case studies demonstrate convergence, robustness, and scalability of the methodology and feasibility in distribution networks. Practical issues are further discussed.