Foraging speed is a key determinant of fitness affecting both foraging success and predator attack survival. In a scramble for food, for instance, evolutionary stable strategy models predict that speed should increase with competitor density and decrease when the risk of attack by predators increases. Foraging speed should also decrease in richer food patches where the level of competition is reduced. I tested these predictions in fall staging flocks of semipalmated sandpipers (Calidris pusilla) foraging for an evasive prey. Capture rate of these prey decreased with sandpiper density as the presence of competitors reduced the availability of resources for those behind. Foraging speed was evaluated indirectly by measuring the time needed to cross fixed boundaries on mudflats over 6 years. As predicted, foraging speed increased with sandpiper density and decreased with food density, but, unexpectedly, increased closer to obstructive cover where predation risk was deemed higher. When foraging closer to cover, from where predators launch surprise attacks, the increase in foraging speed may compensate for an increase in false alarms that interrupted foraging. While foraging in denser flocks decreases foraging success, joining such flocks may also increase safety against predators. In semipalmated sandpipers that occupy an intermediate position in the food chain, foraging behavior is influenced simultaneously by the evasive responses of their prey and by the risk of attack from their own predators.