Dioscorea opposita cultivar Tiegun is an economically important crop with high nutritional and medicinal value. Plants can activate complex and diverse defense mechanisms after infection by pathogenic fungi. Moreover, endophytic fungi can also trigger the plant immune system to resist pathogen invasion. However, the study of the effects of endophytic fungi on plant infection lags far behind that of pathogenic fungi, and the underlying mechanism is not fully understood. Here, the black spot pathogen Alternaria alternata and the endophytic fungus Penicillium halotolerans of Tiegun were identified and used to infect calli. The results showed that A. alternata could cause more severe membrane lipid peroxidation, whereas P. halotolerans could rapidly increase the activity of the plant antioxidant enzymes superoxide dismutase, peroxidase, and catalase; thus, the degree of damage to the callus caused by P. halotolerans was weaker than that caused by A. alternata. RNA sequencing analysis revealed that various plant defense pathways, such as phenylpropanoid biosynthesis, flavonoid biosynthesis, plant hormone signal transduction, and the mitogen-activated protein kinase signaling pathway, play important roles in triggering the plant immune response during fungal infection. Furthermore, the tryptophan metabolism, betalain biosynthesis, fatty acid degradation, flavonoid biosynthesis, tyrosine metabolism, and isoquinoline alkaloid biosynthesis pathways may accelerate the infection of pathogenic fungi, and the ribosome biogenesis pathway in eukaryotes may retard the damage caused by endophytic fungi. This study lays a foundation for exploring the infection mechanism of yam pathogens and endophytic fungi and provides insight for effective fungal disease control in agriculture.