Multiple long-term conditions (MLTCs), or multimorbidity-the co-occurrence of multiple chronic conditions-present a growing challenge for primary care. Existing predictive models typically focus on single outcomes and often fail to capture the temporal and competing-risk structure inherent in longitudinal electronic health records (EHRs). Here, we present SurvivEHR, a generative transformer-based foundation model trained on over 7.6 billion coded events from 23 million patients in UK primary care. SurvivEHR is pre-trained using a competing-risk, time-to-next-event objective, enabling calibrated risk stratification across a broad range of diagnoses, investigations, medications, and mortality events. We show that this pre-training objective yields strong next-event discrimination and learns clinically meaningful patient trajectories. When adapted through fine-tuning, SurvivEHR achieves improved performance on downstream prognostic tasks, including longer-horizon risk prediction, with particular benefits in low-resource settings. By learning longitudinal patient representations directly from routine primary care records, SurvivEHR provides a scalable foundation for developing generalisable clinical risk models that reflect the complexity of MLTCs in primary care.