SummaryVariation partitioning by canonical correspondence analysis (CCA) was applied to analyse spatial variation in the species composition of a weed community for an area of farmland in southern Finland. The farmland, covering 450 ha, was sampled with a 60 m × 60 m grid. Data on weed species were collected along with the following groups of explanatory variables: spatial variables (the terms of second‐order polynomial trend surface regression equation generated on the x and y co‐ordinates of sample quadrats: x, y, x2, xy, y2, x2y and xy2), farmer variables (nine farms), soil variables (four soil types and pH value), crop variables (barley, oats, sugarbeet, potato and turnip rape) and physical variables (area of field, altitude, slope and aspect in four directions). The main variation in species composition along the first and second CCA axes was caused by interplay between farmer and crop variables. Farmer and crop variables explained more of the variation than did soil or physical variables. All the variables were to some extent spatially structured. The spatial variables contributed 54.5% of the total variation, of which pure spatial variation accounted for 12.2%. The highest covariation with spatial variables was detected with farmer (33.7%) and crop variables (25.7%). Variation partitioning by CCA is recommended for studying the relationship between the spatial variation in weed communities and explanatory variables.