AbstractNesting holes are a scarce resource for obligated cavity‐nesting birds and an important selective force for the evolution of aggressive female behaviours, which may be mediated by testosterone (T) levels. It is known that during periods of intense intrasexual competition such as initial breeding stages, females are highly aggressive towards intruding females. Here, we studied the implications of T levels for female–female competition by comparing levels of aggressiveness towards simulated female intruders (decoys) in two populations of the pied flycatcher (Ficedula hypoleuca) with a marked difference in breeding density. To this end, we exposed free‐living females to simulated territorial intrusions during 30 min when nest construction was almost complete. T levels of females were measured at the beginning of incubation under the assumption that they are positively associated with T levels during nest building. We also related aggressiveness to T levels in both populations. Furthermore, we aimed at detecting whether variation of T levels may explain female incubation attendance. Females showed higher T levels in the populations where pied flycatchers were exposed to a higher likelihood of conspecific interactions (high breeding density) than in the population with low breeding density. Female territorial presence, vigilance at the nest box and proximity to decoys were negatively related to circulating T levels in the high‐density population, but not in the low‐density population. Differences in T levels between populations did not result in differences in female incubation attendance, but T levels were negatively related to the incubation attendance in females from the population showing high T levels. In our populations, T levels in females prior to laying reflect the need to defend nesting cavities which is higher at high breeding density and in subdominant females. High T levels are costly in terms of incubation attendance.