For grid-connected islanded connection of microgrid, the synchronization is necessary, but the existing methods solve the problem with high harmonics in the signal. And also, the imbalanced voltage and rate of change of frequency at the microgrid are obtained by the sensor network or by synchronizing relays in many studies, which is an expensive technique. Hence to solve the problem, the paper introduced the automatic adaptive synchronization (A2S) scheme by using optimization and control techniques to synchronize the microgrid with the decentralized generators. The multiple decentralized generators serve the load through the microgrid, the voltage and phase are synchronized with the adaptive neuro-fuzzy inference system (ANFIS). The imbalance among them is sensed by the rain optimization algorithm (ROA). Thus the sensed changes are fed to the controller to provide gating signals accordingly to the cascaded H-bridge multi-level inverter with reduced harmonics. The distributed generator feeds the load through the 14km feeder line and synchronizes the three-phase voltage at 1.9ms with 2.28% distortion.