Aims: Patients with prior infective endocarditis (IE), a prosthetic heart valve, or a cyanotic congenital heart disease (CHD) are considered to be at high risk of IE by guidelines. However, knowledge is sparse on the relative risk of IE between these three groups and compared controls. Methods and results: Using Danish nationwide registries (1996-2015), we identified all patients with prior IE, a prosthetic heart valve, or a complex CHD (defined as tetralogy of Fallot, truncus arteriosus, and transposition of great arteries) as well as matched control populations. Patients were followed up until death, end of study period, IE hospitalization, emigration, or a maximum of 10 years of follow-up, whichever came first. Multivariable adjusted Cox proportional hazard analysis was used to compare the risk of IE between the study groups and the matched controls. We included 25 945 patients: 5096 had prior IE, 19 478 had a prosthetic heart valve, and 1371 had complex CHD. The cumulative risk of IE at 10 years of follow-up was 8.8%, 6.0%, and 1.3% for patients with prior IE, a prosthetic valve, and complex CHD, respectively. Patients with prior IE and a prosthetic valve had a significant increased associated risk of IE compared with the matched controls [hazard ratio (HR) 65.4, 95% confidence interval (CI) 43.1-99.1 and HR 19.1, 95% CI 15.0-24.4), respectively]. No events occurred among the matched controls for the complex CHD group and an HR could not be calculated. Conclusion: All IE high-risk groups carried a higher risk of IE than the matched controls from the general population. These results justify the European and American guidelines in considering these groups at high risk of IE.