Prey often respond to predator presence by increasing their use of refuges, but because this strategy may be costly, the decision regarding when to come out from a refuge should be optimized. The loss of foraging opportunities may be one of the main costs when safer microhabitats (i.e. refuges) are also the poorest in terms of their foraging profitability. We present the results of an experimental field study to test whether emergence times from a refuge of the Iberian rock lizard, Lacerta monticola, vary as a function of expected foraging opportunities and level of satiation of the lizard. As predicted, short-term fluctuations in availability of food influenced emergence times; when a lizard had just detected some food in the recent past, emergence times decreased greatly, because the loss of opportunities for foraging increased costs of refuge use. Furthermore, the characteristics and success of the encounter with food, nutritional state of lizards, and the added possibility of capturing new food items influenced the duration of hiding times. Therefore, foraging requirements and avoidance of predators may be conflicting demands that L. monticola lizards balance by modifying the duration of time spent in refuges.