In response to varying environments along urban and rural gradients, invasive plants may strategically allocate resources to enhance their invasiveness. However, how invasive plants balance their resources for growth, reproduction, and defense as responses to biotic and abiotic factors across these gradients remain unclear. We conducted field surveys on the growth, reproduction, and herbivory of the invasive species Phytolacca americana across diverse urban and rural habitats. Leaf samples were collected to analyze the nutritional content, primary and secondary metabolites. We found that plant growth rates, specific leaf area, leaf nitrogen content, and concentrations of flavonoids and saponins were higher in urban habitats, while reproduction, herbivory, and carbon-to‑nitrogen ratios were lower than those in rural habitats. We also found a trade-off between growth rate and herbivory, as well as trade-offs among defense traits associated with herbivory (e.g., leaf mass per area, the inverse of leaf nitrogen content, and carbon‑nitrogen ratio) and the production of metabolites associated with abiotic stress tolerance (e.g., soluble sugars, flavonoids, and saponins). As earlier studies showed low levels of genetic diversity within and between populations, our findings suggest that the urban–rural gradient patterns of resource allocation are primarily phenotypic plasticity in response to herbivory in rural areas and abiotic factors in urban areas. Our study sheds light on the mechanisms by which urbanization affects plant invasions and offers insights for the implementation of their management strategies.