Importance The extent to which assisted reproductive technology is associated with increased risk of congenital heart defects independent of its known association with twinning remains uncertain. Objective To assess the extent to which assisted pregnancy is associated with increased risk of congenital heart defects independent of its known association with twinning. Design, Setting, and Participants This retrospective cohort study linked records of congenital heart defect diagnoses with assisted reproductive technology cycles in 507 390 singleton or twin pregnancies (10 149 assisted pregnancies and 497 241 nonassisted pregnancies), including singleton and twin early pregnancy losses, stillbirths, and live births (follow-up to 1 year of age) in Ontario, Canada, between April 1, 2012, and October 31, 2015. Statistical analysis was performed from January 1, 2017, to September 9, 2019. Exposures Assisted reproductive technology and its 2 subtypes: intracytoplasmic sperm injection and in vitro fertilization without intracytoplasmic sperm injection. Main Outcomes and Measures The main outcome was congenital heart defects (prevalence and relative risk measured as odds ratios [ORs]). Mediation analysis was performed to assess the extent to which the association between assisted reproductive technology and congenital heart defects was mediated by twinning. Results Of 507 390 mother-infant pairs with singleton or twin pregnancies evaluated, the prevalence of congenital heart defects in assisted pregnancies (223 [2.2%]) was higher than that in nonassisted pregnancies (6057 [1.2%]; crude OR, 1.82; 95% CI, 1.59-2.09). The strength of the association between assisted pregnancy and congenital heart defects decreased after adjusting for several risk factors simultaneously (adjusted OR, 1.70; 95% CI, 1.48-1.95). Further mediation analysis indicated that most of the association between assisted pregnancy and congenital heart defects was mediated by twinning (adjusted OR, 1.68; 95% CI, 1.44-1.92), and the natural direct association of assisted pregnancy with congenital heart defects among singleton pregnancies was 1.09 (95% CI, 0.93-1.25). Mediation of twinning accounted for 87.3% of the association. Conclusions and Relevance Our study results suggest that the association between assisted reproductive technology and congenital heart defects may be mediated by twinning.