Summary To test the hypothesis that competitor density and time spent at a food resource influences aggressive behaviour in male swordtail, Xiphophorus sp., fish were kept at two densities (low: 18 fish m−3; high: 54 fish m−3) and aggressive behaviour was recorded with the time at the food resource used as a covariate. Competitor density is likely to affect the cost:benefit ratio of food defence. When density is low, there should be sufficient food for all individuals and intra-specific interactions are expected to be rare, while at high densities, increased intra-specific encounter rates mean that individuals may spend more time defending a resource than utilising it. Food resource defence should occur at intermediate densities. The frequency of aggression, i.e. bites, chases, and display behaviour was significantly positively influenced by time spent at the food resource (Bites: F1,31 = 8.186, P = 0.007; Chases: F1,31 = 6.439, P = 0.016; Displays: F1,31 = 4.435, P = 0.043) suggesting that food resource defence occurred. Competitor density had no effect on food resource defence and minimal effect on the frequency of aggression with only one type of aggressive behaviour, male–male displays, showing a difference between densities (F1,31 = 6.975, P = 0.013). This finding is suggested to be a result of the formation of dominance hierarchies in this species. Aggression from the dominant individual may be directed at only subordinates of the next dominance rank and subordinate behaviour may be restricted by status rather than immediate threat. In such a situation, aggression may be independent of competitor density.