Co-occurrence of inflammatory bowel disease (IBD) and type 1 diabetes (T1D) has been linked to poor clinical outcomes, but evidence on their bidirectional associations remain scarce. This study aims to investigate their bidirectional associations. A nationwide matched cohort and case-control study with IBD patients identified between 1987 and 2017. The cohort study included 20,314 IBD patients (≤28 years; Crohn's disease [CD, n=7277], ulcerative colitis [UC, n=10,112], and IBD-unclassified [IBD-U, n=2925]) and 99,200 individually matched reference individuals, with a follow-up until December 2021. The case-control study enrolled 87,001 IBD patients (no age restriction) and 431,054 matched controls. We estimated adjusted hazard ratio (aHR) of incident T1D in the cohort study with flexible parametric survival model and adjusted odds ratio (aOR) of having a prior T1D in the case-control study with conditional logistic regression model, with 95% confidence intervals (CI). During a median follow-up of 14 years, 116 IBD patients and 353 reference individuals developed T1D. Patients with IBD had a higher hazard of developing T1D (aHR=1.58 [95% CI=1.27-1.95]). The hazard was increased in UC (aHR=2.02 [1.51-2.70]) but not in CD or IBD-U. In the case-control study, a total of 1018 (1.2%) IBD patients and 3496 (0.8%) controls had been previously diagnosed with T1D. IBD patients had higher odds of having prior T1D (aOR=1.36 [1.26-1.46]). Such positive association was observed in all IBD subtypes. The sibling comparison analyses showed similar associations between IBD and T1D (aHR=1.44 [0.97-2.15] and aOR=1.32 [1.18-1.49]). Patients with IBD had a moderately increased hazard of developing T1D and higher odds of having prior T1D. Their bidirectional associations may be partially independent of shared familial factors. European Crohn's and Colitis Organisation, Stiftelsen Professor Nanna Svartz Fond, SSMF (project#: PG-23-0315-H-02), Ruth and Richard Julin Foundation; and FORTE (project#: 2016-00424).