There is growing evidence that stress during prenatal and postnatal periods of life can modify adaptive capacities in adulthoods. The hypothalamo–pituitary–adrenal axis may mediate an animal's responses to perinatal stressful events and thus serve as a neurobiological substrate of the behavioural consequences of these early events. However, little is known about the long-term effects of prenatal stressors throughout the entire life of the animals. The focus of the present study was to examine the long-term influences of a prenatal and postnatal stress on glucocorticoid secretion and cognitive performance. Prenatal stress of rat dams during the last week of pregnancy and postnatal daily handling of rat pups during the first 3 weeks of life were used as stressors. The long-term effects of these manipulations were analysed using a longitudinal approach throughout the entire life of the animals, and were repeatedly tested in adulthood (4–7 months), middle age (13–16 months) and in later life (20–24 months). The study demonstrated that prenatal stress and postnatal handling induced opposite effects on both glucocorticoid secretion and cognitive performance. Prenatal stress accelerated the age-related hypothalamo–pituitary–adrenal axis dysfunctions; indeed, circulating glucocorticoids levels of prenatally stressed middle-aged animals are similar to old control ones, and also induced cognitive impairments. In contrast, postnatal handling protected from the age-related neuroendocrine and behavioural alterations. These results show that the altered glucocorticoid secretion induced by early environmental manipulations is primary to the cognitive alterations observed only later in life and could be one cause of age-related memory deficits.