To inform targeted public health strategies, it is crucial to understand how coexisting diseases develop over time and their associated impacts on patient outcomes and health-care resources. This study aimed to examine how psychosis, diabetes, and congestive heart failure, in a cluster of physical-mental health multimorbidity, develop and coexist over time, and to assess the associated effects of different temporal sequences of these diseases on life expectancy in Wales. In this retrospective cohort study, we used population-scale, individual-level, anonymised, linked, demographic, administrative, and electronic health record data from the Wales Multimorbidity e-Cohort. We included data on all individuals aged 25 years and older who were living in Wales on Jan 1, 2000 (the start of follow-up), with follow-up continuing until Dec 31, 2019, first break in Welsh residency, or death. Multistate models were applied to these data to model trajectories of disease in multimorbidity and their associated effect on all-cause mortality, accounting for competing risks. Life expectancy was calculated as the restricted mean survival time (bound by the maximum follow-up of 20 years) for each of the transitions from the health states to death. Cox regression models were used to estimate baseline hazards for transitions between health states, adjusted for sex, age, and area-level deprivation (Welsh Index of Multiple Deprivation [WIMD] quintile). Our analyses included data for 1 675 585 individuals (811 393 [48·4%] men and 864 192 [51·6%] women) with a median age of 51·0 years (IQR 37·0-65·0) at cohort entry. The order of disease acquisition in cases of multimorbidity had an important and complex association with patient life expectancy. Individuals who developed diabetes, psychosis, and congestive heart failure, in that order (DPC), had reduced life expectancy compared with people who developed the same three conditions in a different order: for a 50-year-old man in the third quintile of the WIMD (on which we based our main analyses to allow comparability), DPC was associated with a loss in life expectancy of 13·23 years (SD 0·80) compared with the general otherwise healthy or otherwise diseased population. Congestive heart failure as a single condition was associated with mean a loss in life expectancy of 12·38 years (0·00), and with a loss of 12·95 years (0·06) when preceded by psychosis and 13·45 years (0·13) when followed by psychosis. Findings were robust in people of older ages, more deprived populations, and women, except that the trajectory of psychosis, congestive heart failure, and diabetes was associated with higher mortality in women than men. Within 5 years of an initial diagnosis of diabetes, the risk of developing psychosis or congestive heart failure, or both, was increased. The order in which individuals develop psychosis, diabetes, and congestive heart failure as combinations of conditions can substantially affect life expectancy. Multistate models offer a flexible framework to assess temporal sequences of diseases and allow identification of periods of increased risk of developing subsequent conditions and death. Health Data Research UK.