Tanshinones are bioactive ingredients derived from the herbal plant Salvia miltiorrhiza and are used for treating diseases of the heart and brain, thus ensuring quality of S. miltiorrhiza is paramount. Applying the endophytic fungus Trichoderma atroviride D16 can significantly increase the content of tanshinones in S. miltiorrhiza, but the potential mechanism remains unknown. In the present study, the colonization of D16 effectively enhanced the levels of Ca2+ and H2O2 in the roots of S. miltiorrhiza, which is positively correlated with increased tanshinones accumulation. Further experiments found that the treatment of plantlets with Ca2+ channel blocker (LaCl3) or H2O2 scavenger (DMTU) blocked D16-promoted tanshinones production. LaCl3 suppressed not only the D16-induced tanshinones accumulation but also the induced Ca2+ and H2O2 generation; nevertheless, DMTU did not significantly inhibit the induced Ca2+ biosynthesis, implying that Ca2+ acted upstream in H2O2 production. These results were confirmed by observations that S. miltiorrhiza treated with D16, CaCl2, and D16+LaCl3 exhibit H2O2 accumulation and influx in the roots. Moreover, H2O2 as a downstream signal of Ca2+ is involved in D16 enhanced tanshinones synthesis by inducing the expression of genes related to the biosynthesis of tanshinones, such as DXR, HMGR, GGPPS, CPS, KSL and CYP76AH1 genes. Transcriptomic analysis further supported that D16 activated the transcriptional responses related to Ca2+ and H2O2 production and tanshinones synthesis in S. miltiorrhiza seedlings. This is the first report that Ca2+ and H2O2 play important roles in regulating fungal-plant interactions thus improving the quality in the D16-S. miltiorrhiza system.