Objective No previous study has focused on recognition of myocardial infarction (MI) and the presence of both depressive and anxiety disorders in a large population-based sample. The aim of this study was to investigate the association of recognized MI (RMI) and unrecognized MI (UMI) with depressive and anxiety disorders. Methods Analyses included 125,988 individuals enrolled in the Lifelines study. Current mental disorders according to the Diagnostic and Statistical Manual of Mental Disorders (Fourth Edition) were assessed with the Mini-International Neuropsychiatric Interview. UMI was detected using electrocardiogram in participants who did not report a history of MI. The classification of RMI was based on self-reported MI history together with the use of either antithrombotic medications or electrocardiogram signs of MI. Analyses were adjusted for age, sex, smoking, somatic comorbidities, and physical health-related quality of life as measured by the RAND 36-Item Health Survey in different models. Results Participants with RMI had significantly higher odds of having any depressive and any anxiety disorder as compared with participants without MI (depressive disorder: Odds ratio [OR] = 1.86, 95% confidence interval [CI] = 1.38-2.52; anxiety disorder: OR = 1.60, 95% CI = 1.32-1.94) after adjustment for age and sex. Participants with UMI did not differ from participants without MI (depressive disorder: OR = 1.60, 95% CI = 0.96-2.64; anxiety disorder: OR = 0.73, 95% CI = 0.48-1.11). After additional adjustment for somatic comorbidities and low physical health-related quality of life, the association between RMI with any depressive disorder was no longer statistically significant (OR = 1.18; 95% CI =0.84-1.65), but the association with any anxiety disorder remained (OR = 1.27, 95% CI = 1.03-1.57). Conclusions Recognition of MI seems to play a major role in the occurrence of anxiety, but not depressive, disorders.