Contamination of soil with toxic heavy metals poses a major threat to the environment and human health. Anthropogenic sources include smelting of ores, municipal wastes, fertilizers, and pesticides. In assessing soil quality and the environmental and ecological risk of contamination with heavy metals, often homogeneous contamination of the soil is assumed. However, soils are very heterogeneous environments. Consequently, both contamination and the response of soil organisms can be assumed to be heterogeneous. This might have consequences for the exposure of soil organisms and for the extrapolation of risk from the individual to the population level. Therefore, to explore how soil contamination of different spatial heterogeneity affects population dynamics of soil invertebrates, we developed a spatially explicit individual-based model of the springtail, Folsomia candida, a standard test species for ecotoxicological risk assessment. In the model, individuals were assumed to sense and avoid contaminated habitat with a certain probability that depends on contamination level. Avoidance of contaminated areas thus influenced the individuals’ movement and feeding, their exposure, and in turn all other biological processes underlying population dynamics. Model rules and parameters were based on data from the literature, or were determined via pattern-oriented modelling. The model correctly predicted several patterns that were not used for model design and calibration. Simulation results showed that the ability of the individuals to detect and avoid the toxicant, combined with the presence of clean habitat patches which act as “refuges”, made equilibrium population size due to toxic effects less sensitive to increases in toxicant concentration. Additionally, the level of heterogeneity among patches of soil (i.e. the difference in concentration) was important: at the same average concentration, a homogeneously contaminated scenario was the least favourable habitat, while higher levels of heterogeneity corresponded to higher population growth rate and equilibrium size. Our model can thus be used as a tool for extrapolating from short-term effects at the individual level to long-term effects at the population level under more realistic conditions. It can thus be used to develop and extrapolate from standard ecotoxicological tests in the laboratory to ecological risk assessments.