This paper presents an advanced control strategy for balancing the time-varying and unbalanced loads by using the fuel cell and battery under the grid-tied and off-grid operations. In the grid-tied operation, the fuel cell and the battery are coordinately controlled to balance the three-phase unbalanced active and reactive powers of the loads. In this case, the received three-phase active-reactive powers from the grid become completely balanced by the given strategy. In the off-grid, the diesel generator supplies the active-reactive powers of load and the unbalances are handled by coordinated operation of fuel cell and battery. As well, the voltage of off-grid system is improved by injecting adequate reactive power to the system through the fuel cell, battery and diesel generator. The dynamic stability of the system is evaluated under non-linear disturbances like grid outage and single-phase fault. The time-varying unbalanced active-reactive powers are balanced under both off-grid and grid-tied states by implementing the proposed model. The purpose of the proposed control system is to balance the unbalanced load from point of view of the upstream grid at all time periods. In order to realize such function in the model, the load is modeled by two terms including the balanced and unbalanced parts. The unbalanced share is supplied by the inverters (DC bus) and the balanced term of load is supplied by the grid. The designed system is resilient under the events like grid outage and short circuits. As well, the system properly regulates and controls the load variations and unbalances.