The mechanisms that trigger the switch from endophytic fungi to saprophytic fungi are largely unexplored. Broad host range Phomopsis liquidambari is established in endophytic and saprophytic systems with rice (Oryza sativa L.). Endophytic P. liquidambari promotes rice growth, increasing rice yield and improving the efficiency of nitrogen fertilizer. This species's saprophytic counterpart can decompose rice litterfall, promoting litter organic matter cycling and the release of nutrients and improving the soil microbial environment. Fluorescence microscopy, confocal laser scanning microscopy and quantitative PCR investigated the colonization dynamics and biomass of P. liquidambari in rice in vivo. P. liquidambari formed infection structures similar to phytopathogens with infected vascular tissues that systematically spread to acrial parts. However, different from pathogenic infection, P. liquidambari colonization exhibits space restriction and quantity restriction. Direct comparison of a fungal transcriptome under three different habitats provided a better understanding of lifestyle conversion during plant-fungi interactions. The isolated total RNA of Ck (pure culture), EP (endophytic culture) and FP (saprophytic culture) was subjected to Illumina transcriptome sequencing. To the best of our knowledge, this study is the first to investigate Phomopsis sp. using RNA-seq technology to obtain whole transcriptome information. A total of 27,401,258 raw reads were generated and 22,700 unigenes were annotated. Functional annotation indicated that carbohydrate metabolism and biosynthesis of secondary metabolites played important roles. There were 2522 differentially expressed genes (DEGs) between the saprophytic and endophytic lifestyles. Quantitative PCR analysis validated the DEGs of RNA-seq. Analysis of DEGs between saprophytic and endophytic lifestyles revealed that most genes from amino acids metabolism, carbohydrate metabolism, fatty acid biosynthesis, secondary metabolism and terpenoid and steroid biosynthesis were up-regulated in EP. Secondary metabolites of these pathways may affect fungal growth and development and contribute to signaling communication with the host. Most pathways of xenobiotic biodegradation and metabolism were upregulated in FP. Cytochrome P450s play diverse vital roles in endophytism and saprophytism, as their highly specialized functions are evolutionarily adapted to various ecological niches. These results help to characterize the relationship between fungi and plants, the diversity of fungi for ecological adaptations and the application prospects for fungi in sustainable agriculture.