We applied optimal foraging theory to test effects of habitat and predation risk on foraging behavior of mule deer (Odocoileus hemionus) subject to predation by mountain lions (Puma concolor). We predicted that deer would spend less time foraging, have higher giving-up densities of food (GUDs), and have higher vigilance behavior when occupying patch edges than when in open and forest interiors. We also measured GUDs in 3 microhabitats within 3 forest types. We used pellet-group surveys to estimate habitat and microhabitat use, and we assessed vigilance behavior with automatic camera systems. The GUDs (perceived predation risk) were greater in forests of Douglas fir (Pseudostuga menziensii) than mountain mahogany (Cercocarpus ledifolius). In forests of Douglas fir, GUDs were greatest in the forest interior, declined at the forest edge, and were lowest in the open microhabitat. Microhabitat features did not influence GUDs in the mountain mahogany forest. Pellet-group data indicated more activity in the open than in the edge or forest. Based on photographs, deer were more vigilant at forest edges than in open and forest areas. We concluded that deer are responding to predation risk by biasing their feeding efforts at the scale of habitats and microhabitats and altering their habitat-specific patterns of vigilance behavior.