This study explored the effects of four sugar source treatments, including no sugar (CON), fructose (FRU), pectin (PEC), and starch (STA), on the microbiota and metabolome of alfalfa (Medicago sativa) silage. The bacterial community was determined via 16S rRNA gene sequencing. The metabolome was analyzed using ultra high-performance liquid chromatography tandem time-of-flight mass spectrometry (UHPLC/TOF-MS). After 60 days of fermentation, the pH values in FRU and PEC were lower than those in STA and CON. FRU had a greater lactic acid concentration compared to STA and CON. Weissella (47.44%) and Lactobacillus (42.13%) were the dominant species in all four groups. The abundance of Pediococcus was lower, and the abundance of Leuconostoc, Pantoea, and Microbacterium was higher, in FRU compared to CON. The abundance of norank_f__Bacteroidales_S24-7_group was higher, and the abundance of Turicibacter was lower, in both FRU and PEC than in CON. Leuconostoc was negatively correlated with the pH value, and Pediococcus was positively correlated with the pH value. No microbiomes were detected as discriminative features between STA and CON. The addition of FRU and PEC presented more peptides, such as Leu-Val-Thr, Leu-Phe, Ile-Pro-Ile, Val-Trp, and Ile-Leu-Leu but a lower abundance of metabolites for triterpene glycosides including sanchinoside B1, medicagenic acid, betavulgaroside IV, and prosapogenin compared to CON. The addition of PEC presented more phenyllactic acid compared to CON. Our study demonstrated that the addition of pectin and fructose improved the quality of alfalfa silage mainly by promoting Leuconostoc, Pantoea, and Microbacterium, and inhibiting Pediococcus in FRU, and promoting norank_f__Bacteroidales_S24-7_group and inhibiting Turicibacter in both FRU and PEC; this was due to altered metabolic profiles resulting from antifungal activity and decreased triterpene glycoside accumulation. This study improves our understanding of ensiling mechanisms related to the contributions of sugar.