While many studies on foraging have related energy gain to the density and the size of prey, only few have investigated whether and how habitat structure modifies the gain through affecting foraging success. In this study, the influences of habitat structure and prey characteristics on the foraging success of water pipits, Anthus spinoletta, were investigated experimentally. The birds take longer to find prey in tall than in short vegetation. The effects of vegetation on searching times differ between prey types. These differences are probably caused by variation in prey behaviour and in cryptic colouration, but not by prey size. Searching times increase with decreasing density for mealworms and tipulids, but not for caterpillars. Handling large prey items requires more time than handling smaller prey. Tipulids and caterpillars, which were offered alive, are handled for a longer time than dead mealworms of corresponding size. The success of attacks on flying insects is probably influenced by the prey's flight speed: fast houseflies are missed more often than slow tipulids. Overall, the results show that the time costs of foraging water pipits are influenced to a comparable degree by vegetation structure, by prey density and by other specific prey characteristics such as camouflage, hiding behaviour or agility. The amount of food gathered per unit time is determined primarily by factors that affect searching times, and less by handling and travelling times. Insertion of our data into an optimal diet model leads to the prediction that water pipits should be generalist foragers, which agrees with the observed behaviour.