This paper proposes a consensus tracking control method for energy management and state-of-charge (SoC) balancing of energy storage batteries in the grid-connected mode of AC microgrids. By adding a target power term to the consensus average control law, taking into account battery energy storage system (BESS) with various SoCs and various capacities, the stability and robustness of the proposed consensus control approach are analytically validated. Simulations of a state–space battery model and a detailed dynamic model of batteries in grid-connected mode are constructed in a Matlab environment. A detailed study of weighting matrices of the control approach is presented, and their suitable range is identified. The results show that the proposed method could effectively balance SoC for batteries of equal and different capacities, allowing the battery with the higher capacity to charge and discharge more than the others at the same time while still maintaining the target power. Furthermore, the controller successfully prevented deep discharge or overcharging of the batteries by disconnecting them when they reached their SoC limitations and compensating for this disconnection by raising their target power to maintain the same load.