Colectomy and reconstruction in patients with inflammatory bowel disease [IBD] may adversely affect fertility, but few population-based studies on this subject are available. Fertility was assessed in 2989 women and 3771 men with IBD and prior colectomy during 1964-2014, identified from the Swedish National Patient Register, and in 35 092 matched individuals. Reconstruction with ileoanal pouch anastomosis [IPAA] was as common as ileorectal anastomosis [IRA] in ulcerative colitis [UC] and IBD-unclassified [IBD-U] but rare in Crohn's disease [CD]. Compared with the matched reference cohort, women with IBD had lower fertility overall after colectomy (hazard ratio [HR] 0.65, confidence interval [CI] 0.61-0.69), with least impact with leaving the rectum intact [HR 0.79, CI 0.70-0.90]. Compared with colectomy only, fertility in female patients remained unaffected after IRA [HR 0.86, CI 0.63-1.17 for UC, 0.86, CI 0.68-1.08 for IBD-U and 1.07, CI 0.70-1.63 for CD], but was impaired after IPAA, especially in UC [HR 0.67, CI 0.50-0.88], and after completion proctectomy [HR 0.65, CI 0.49-0.85 for UC, 0.68, CI 0.55-0.85 for IBD-U and 0.61, CI 0.38-0.96 for CD]. In men, fertility was marginally reduced following colectomy [HR 0.89, CI 0.85-0.94], regardless of reconstruction. Fertility was reduced in women after colectomy for IBD. The least impact was seen when a deviated rectum was left intact. IRA was associated with no further reduction in fertility, whereas proctectomy and IPAA were associated with the strongest impairment. IRA therefore seems to be the preferred reconstruction to preserve fertility in selected female patients. Fertility in men was only moderately reduced after colectomy.