The swnH1 gene in the endophytic fungus Alternaria oxytropis OW 7.8 isolated from Oxytropis glabra was identified, and the gene knockout mutant ΔswnH1 was first constructed in this study. Compared with A. oxytropis OW 7.8, the ΔswnH1 mutant exhibited altered colony and mycelium morphology, slower growth rate, and no swainsonine (SW) in mycelia, indicating that the function of the swnH1 gene promoted SW biosynthesis. Five differential expressed genes (DEGs) closely associated with SW synthesis were identified by transcriptomic analysis of A. oxytropis OW 7.8 and ΔswnH1, with sac, swnR, swnK, swnN, and swnH2 down-regulating. Six differential metabolites (DEMs) closely associated with SW synthesis were identified by metabolomic analysis, with P450, PKS-NRPS, saccharopine, lipopolysaccharide kinase, L-PA, α-aminoadipic, and L-stachydrine down-regulated, while L-proline was up-regulated. The SW biosynthetic pathways in A. oxytropis OW 7.8 were predicted and refined. The results lay the foundation for in-depth exploration of the molecular mechanisms and metabolic pathways of SW synthesis in fungi and provide reference for future control of SW in locoweeds, which would benefit the development of animal husbandry and the sustainable use of grassland ecosystems.