People with physical diseases are reported to be at elevated risk of subsequent mental disorders. However, previous studies have considered only a few pairs of conditions, or have reported only relative risks. This study aimed to systematically explore the associations between physical diseases and subsequent mentaldisorders. It examined a population-based cohort of 7,673,978 people living in Denmark between 2000 and 2021, and followed them for a total of 119.3 million person-years. The study assessed nine broad categories of physical diseases (cardiovascular, endocrine, respiratory, gastrointestinal, urogenital, musculoskeletal, hematological and neurological diseases, and cancers), encompassing 31 specific diseases, and the subsequent risk of mental disorder diagnoses, encompassing the ten ICD-10 groupings (organic, including symptomatic, mental disorders; mental disorders due to psychoactive substance use; schizophrenia and related disorders; mood disorders; neurotic, stress-related and somatoform disorders; eating disorders; personality disorders; intellectual disabilities; pervasive developmental disorders; and behavioral and emotional disorders with onset usually occurring in childhood and adolescence). Using Poisson regression, the overall and time-dependent incidence rate ratios (IRRs) for pairs of physical diseases and mental disorders were calculated, adjusting for age, sex and calendar time. Absolute risks were estimated with the Aalen-Johansen estimator. In total, 646,171 people (8.4%) were identified as having any mental disorder during follow-up. All physical diseases except cancers were associated with an elevated risk of any mental disorder. For the nine broad pairs of physical diseases and mental disorders, the median point estimate of IRR was 1.51 (range: 0.99-1.84; interquartile range: 1.29-1.59). The IRRs ranged from 0.99 (95% CI: 0.98-1.01) after cancers to 1.84 (95% CI: 1.83-1.85) after musculoskeletal diseases. Risks varied over time after the diagnosis of physical diseases. The cumulative mental disorder incidence within 15 years after diagnosis of a physical disease varied from 3.73% (95% CI: 3.67-3.80) for cancers to 10.19% (95% CI: 10.13-10.25) for respiratory diseases. These data document that most physical diseases are associated with an elevated risk of subsequent mental disorders. Clinicians treating physical diseases should constantly be alert to the possible development of secondary mental disorders.