Plants need to prioritize their responses to simultaneous stresses, including colonization by microbes or nutrient starvation. The endophytic fungusColletotrichum tofieldiae (Ct) improves phosphate absorption in plants and promotes growth of Arabidopsis thaliana under phosphate deficient conditions. Comparative genomics of this fungus with related pathogens of the same genus indicates that the transition of Ct from parasitism to mutualism is relatively recent. Mutualistic behaviour is revealed by a narrowed repertoire of secreted effector proteins and a limited activation of pathogenicity-related genes in planta. Beneficial responses are prioritized in Ct-colonized roots under phosphate-deficient conditions, whereas defence responses are activated under phosphate sufficient conditions. These immune responses are retained in phosphate-starved roots colonized by the related pathogen C. incanum, illustrating the ability of plants to maximize survival in response to conflicting stresses.