Over 11 winters I examined the interactions between sparrowhawk Accipiter nisus attack behaviour, the gregariousness of redshanks Tringa totanus and local geography to test hypotheses that suggest birds should flock to reduce their risk of predation and that predation risk should decline with the prey's distance from cover. Sparrowhawk attacks on redshanks feeding on beaches around the high tide mark (the strandline zone) were more frequent and more successful than attacks on redshanks feeding seaward of the strandline zone (in the intertidal zone). The results therefore confirmed hypothetical expectations that predation risk should decline with distance from cover. Flocking only appeared to influence the outcome of hawk attacks at shorter distances from cover on the strandline, with attacks on singletons and small flocks being more successful than attacks on larger flocks. Distance from cover had a stronger influence on the likelihood of attack success than did flock size. Mid-range flock sizes (6–45 birds) were attacked more frequently than expected, but singletons and large flocks were attacked less than expected. Despite these differences an individual redshank's likelihood of predation by a sparrowhawk declined with increasing flock size, thereby confirming the ‘dilution effect’ and ‘vigilance’ hypotheses for the evolution of flocking in birds. Food intake rates of redshanks declined with increasing flock size, further indicating that redshanks flocked to avoid predation rather than to increase their food intake rates. The strong interaction between two influences on predation risk revealed by the present study suggests other studies should take great care when considering a single influence on predation risk in isolation from others.