Though the interplay of grazing intensity and the availability of resources is a key driver in grassland composition, very few studies focused on trait changes after abandonment along productivity gradients. Through a comparative approach, we aimed to assess the context-dependent effects of long-term grazing cessation on functional composition and diversity in sub-Mediterranean grasslands. We hypothesized that variability of topography, soil and vegetation structure on a fine scale drives the trait-based dynamics after long-term abandonment, also influencing the patterns of functional diversity. On a calcareous mountain ridge of central Italy, we collected data on species cover and traits, site characteristics, soil depth and vegetation structure in 0.5 m × 0.5 m plots located in extensively grazed pastures and in grasslands abandoned since the early 1970s. We analysed patterns of species and traits in relation to environmental variables and management type, and trends in functional diversity (FD, Rao’s quadratic entropy) along a productivity gradient. We found that grazing cessation reduced the overall FD and that the direction of species and trait response after long-term grazing cessation were affected, on a fine scale, by the soil depth / productivity gradient. In dryer conditions, species and functional responses were less affected by abandonment, and were devoted to resistance to both stress and disturbance. In abandoned pastures we detected a significant decrease in FD with increasing productivity, leading to a shift from functional strategies devoted to grazing avoidance and tolerance to those devoted to competition for light and resource acquisition. This trend was related to the filtering effect of coarse tall grasses, which spread in highly productive conditions. In grazed grasslands, we detected an overall increasing trend of FD with increasing productivity, confirming the key role of extensive grazing in maintaining high levels of FD.