In this paper a comprehensive, primary and secondary control of a grid-connected inverter in the role of microgrid interface unit is presented. A goal-function-based decentralized control structure is proposed as a core of the primary control. It secures the microgrid stability by constraining the frequency and node deviations across the grid while simultaneously supporting the desired active power exchange between prosumer nodes. To demonstrate its effectiveness, results obtained from the simulation model, which includes microgrid inverters’ secondary control, primary control, and inner control loops together with appropriate LCL filter are presented.