Dendroctonus valens LeConte is one of the most economically important forest pest in China. Leptographium procerum, a mutualistic fungus can assist the host beetle in overcoming the pine's chemical defenses, and Beauveria bassiana, an entomopathogenic fungus has shown high beetle killing efficiency. Considering that the D. valens immune system remains unknown at the genomic level, a mutualistic and antagonistic fungus associated with the beetle provides an ideal model for studying immune interactions between the insect and associated fungi. Here, B. bassiana killed most tested larvae more effectively than L. procerum and Tween. The entomopathogenic fungus provoked stronger responses than the symbiotic fungus at the transcriptome level. We identified 185 immunity-related genes, including pattern recognition receptors, signal modulators, members of immune pathways (Toll, IMD, and JAK/STAT), and immune effectors. Quantitative real-time PCR analysis confirmed that several recognition receptors and effector genes were activated at 1 or 2 days post infection, while the effector genes were suppressed at 4 days post infection by B. bassiana, respectively. In contrast, effector genes were upregulated in response to L. procerum. Together, this study provides a comprehensive sequence resource and insight into the D. valens immune system and lays a basis for understanding the molecular aspects of the interaction between the host and associated fungi.