ABSTRACT Root‐knot nematodes (RKNs; Meloidogyne spp.) are a serious threat to crop production. The competition between plants and pathogens for assimilates influences the outcome of their interactions. However, the mechanisms by which plants and nematodes compete with each other for assimilates have not been elucidated. In this study, we demonstrated that miR396a plays a negative role in defense against RKNs and a positive role in sugar accumulation in tomato roots. The overexpression of SlGRF8 ( Solanum lycopersicum growth‐regulating factor 8 ), the target of miR396a, decreased the sugar content of the roots and the susceptibility to RKNs, whereas the grf8‐cr mutation had the opposite effects. Furthermore, we confirmed that SlGRF8 regulated the sugar content in roots by directly activating the transcription of SlSTP10 ( Solanum lycopersicum sugar transporter protein 10 ) in response to RKN stress. Moreover, SlSTP10 was expressed primarily in the tissues surrounding giant cells, and the SlSTP10 knockout increased both the sugar content in the roots and the plant's susceptibility to RKNs. Overall, this study provides important insight into the molecular mechanism through which the miR396a‐SlGRF8‐SlSTP10 module regulates sugar allocation in roots under RKN stress.