Remote and regional areas are usually supplied by isolated and self-sufficient electricity systems, which are called as microgrids (MGs). To reduce the overall cost of electricity production, MGs rely on non-dispatchable renewable sources. Emergencies such as overloading or excessive generation by renewable sources can result in a substantial voltage or frequency deviation in MGs. This paper presents a supervisory controller for such emergencies. The key idea is to remedy the emergencies by optimal internal or external support. A multi-level controller with soft, intermedial and hard actions is proposed. The soft actions include the adjustment of the droop parameters of the sources and the controlling of the charge/discharge of energy storages. The intermedial action is exchanging power with neighboring MGs, which is highly probable in large remote areas. As the last remedying resort, curtailing loads or renewable sources are assumed as hard actions. The proposed controller employs an optimization technique consisting of certain objectives such as reducing power loss in the tie-lines amongst MGs and the dependency of an MG to other MGs, as well as enhancing the contribution of renewable sources in electricity generation. Minimization of the fuel consumption and emissions of conventional generators, along with frequency and voltage deviation, is the other desired objectives. The performance of the proposal is evaluated by several numerical analyses in MATLAB Ò .