In this paper, a distributed hierarchical control is proposed for ac microgrid, which could apply to both grid-connected (GC) mode and islanded (IS) mode as well as mode transitions. The control includes three control levels: 1) the basic droop control is adopted as the primary control; 2) the secondary control is based on the distributed control with a leaderâĂ”follower consensus protocol; and 3) the tertiary level is a mode-supervisory control, which manages the different control targets of four operation modes. Under the proposed control framework, the following targets are achieved: 1) the frequency/voltage recovery and accurate power sharing in IS mode; 2) flexible power flow regulation between utility-grid and microgrid in GC mode; 3) universal control strategy from GC to IS modes without control switching; and 4) smooth active-synchronization from IS mode to GC mode. In this sense, the proposed method can adapt to all four operation modes of microgrid. Compared with central-standard hierarchical control, the proposed method only requires local neighbor-to-neighbor interaction with a sparse distributed communication network. Thus, the scalability, flexibility, reliability, and robustness are greatly improved in practical application. In addition, stability analysis is added to facilitate the control parameter designs, and substantial simulation cases are provided to validate the control feasibility, link-failure-resiliency, and plug-and-play capability.