Immune checkpoint inhibitors are becoming an increasingly common treatment for advanced gastrointestinal cancer, but the possibility of immune-related adverse events has raised concerns. This study aimed to evaluate the risks of immune-related adverse events between patients who received immune checkpoint inhibitors and those who received chemotherapy among different types of gastrointestinal cancer. The study utilized data from the multicenter TriNetX database in the United States covering the period between 2015 and 2022. Hazard ratios and 95% confidence intervals were used to describe the relative hazard of immune-related adverse events based on comparing time-to-event rates. Our study revealed that the incidence of immune-related adverse events was significantly higher in patients who received immune checkpoint inhibitors and chemotherapy compared to those who received chemotherapy only in treating gastrointestinal cancer. CTLA-4 inhibitors tended to have a higher rate of immune-related adverse events compared to PD-1/PD-L1 inhibitors. Our study found a lower mortality rate among patients who developed immune-related adverse events compared to those who did not after propensity score matching (HR, 0.661; 95% CI 0.620-0.704; p < .01). We provide important real-world data on the incidence and impact of immune-related adverse events in patients with advanced gastrointestinal cancer treated with immune checkpoint inhibitors. Our study's results support clinicians in making informed decisions about the potential benefits and risks of immune checkpoint inhibitor therapy for patients with gastrointestinal cancer.