We conducted an investigation to determine the potential of mitochondrial-related genes as diagnostic biomarkers in ulcerative colitis (UC), while also examining their association with immune cell infiltration. To achieve this, we acquired four datasets pertaining to UC, which included gene expression arrays and clinical data, from the GEO database. Subsequently, we selected three signature genes (PDK2, CHDH, and ALDH5A1) to construct a diagnostic model for UC. The nomogram and ROC curves exhibited exceptional diagnostic efficacy. Following this, quantitative real-time polymerase chain reaction and western blotting assays validated the decreased mRNA and protein expression of PDK2, CHDH, and ALDH5A1 in the model of UC cells and dextran sulfate sodium salt (DSS)-induced mice colitis tissues, aligning with the findings in the risk model. This investigation suggested a negative correlation between the expression of ALDH5A1, CHDH, and PDK2 and the infiltration of M1 macrophages. Then, immunofluorescence analysis confirmed the augmented expression of CD86 in the tissue of mice subjected to DSS, while a diminished expression of ALDH5A1, CHDH, and PDK2 was observed. Consequently, it can be inferred that targeting mitochondria-associated genes, namely PDK2, CHDH, and ALDH5A1, holds potential as a viable strategy for prognostic prediction and the implementation of immune therapy for UC.