Introduction: Implementation of psychological interventions in prisoners in order to improve their mental health is one of the necessary measures in the state prisons and security and corrective measures organization. Due to the importance of this issue, the present study was conducted to investigate the effect of cognitive behavioral therapy (CBT) on cognitive flexibility (CF) in prisoners. Methods: This study was a quasi-experimental design with pre-test, post-test and control group, which was conducted in 2019 in the statistical population of non-financial prisoners in Ahvaz Central Prison. By purposeful sampling method, 40 prisoners were placed in two experimental and control groups. After receiving the pre-test, the experimental group underwent 8 sessions of CBT. The Cognitive Flexibility Inventory-CFI (Dennis & Vander, 2010) was used in the assessment process. Data analysis was performed using SPSS-21 statistical software. Results: The results indicated that the intervention played an effective role in increasing the perceptual components of different options (P = 0. 002, F = 11. 632) and controllability perception (P = 0. 002, F = 12. 044) as well as the CFI (P = 0. 0001, F = 27. 298) (P <0. 001); However, no significant difference was observed in the behavior perception component (P = 0. 942, F = 0. 005). Generally, CBT intervention was able to explain 0. 50 of the changes in CF. Conclusions: CBT Intervention has the potential to increase cognitive flexibility by modifying dysfunctional beliefs and behavioral activation. Based on this, it is suggested that the role of CBT intervention be considered in line with security and corrective measures.