It has often been suggested that mood and personality predispose to peptic ulcer, but little prospective evidence exists. We used longitudinal data from the Alameda County Study to seek associations of psychological characteristics with later ulcer development, taking into account the possible confounding or mediating, taking into account the possible confounding or mediating roles of nonpsychological factors. Among 4,595 Alameda County Study subjects ulcer-free in 1965, we studied five baseline psychological measures (depression, hostility, ego resiliency, social alienation or anomy, and personal uncertainty) with respect to reported ulcer in 1973-1974. All five measures had significant age-adjusted associations with incident ulcer [odds ratio (O.R.) 1.8-2.6]. After adjustment for smoking, drinking, skipping breakfast, lack of sleep, painful medical conditions, and liver disease, three measures remained significant: depression, anomy, and hostility. The age-adjusted O.R. of 2.8 [95% confidence interval (C.I.) 1.6, 4.8] for an upper versus a lower tertile index of independently predictive psychological factors fell to 2.1 with adjustment for health-related behaviors and medical conditions, and reached 1.7 (C.I. 1.0, 3.1) after addition of education to the model. We conclude that depression, maladjustment, and hostility are prospectively associated with peptic ulcer. These associations are partially accounted for by confounding or mediation by standard risk factors, and are to some extent related to socioeconomic status.