Considering the role of T helper (Th)17 cells in the pathogenesis of ankylosing spondylitis (AS), the aim of this study was to determine the correlation between aryl hydrocarbon receptor (AHR) gene expression and the expression of Th17-related genes including interleukin (IL)-17 and RAR-related orphan receptor gamma t (RORγt) transcription factor. Thirty patients with AS (26 males, 4 females; mean age: 36.1±8.1 years) and 30 age- and sex-matched healthy individuals (26 males, 4 females; mean age: 36.2±14.6 years) were recruited for the case-control study between June 2021 and January 2022. Ribonucleic acid (RNA) was extracted from peripheral blood cells and expression levels of AHR, IL-17, RORγt, and AHR repressor (AHRR) genes were evaluated using real-time polymerase chain reaction technique. The serum level of IL-17 was evaluated with enzyme-linked immunosorbent assay. The results showed a nonsignificant elevation of AHR, IL-17, and RORγt gene expression in the patient group compared to the control. There was a direct correlation between AHR gene expression and IL-17 and RORγt genes and a negative correlation between AHR and AHRR expression. Moreover, AHR gene expression showed a weak correlation with disease activity indices, including Bath Ankylosing Spondylitis Disease Activity Index, Bath Ankylosing Spondylitis Functional Index, Bath Ankylosing Spondylitis Metrology Index, Bath Ankylosing Spondylitis Global Score, and Ankylosing Spondylitis Quality of Life. Moreover, the serum level of IL-17 was higher in AS patients compared to the healthy group (p=0.02). Upregulated expression of the AHR gene in ankylosing spondylitis and its correlation with IL-17 and ROR-γ t gene expression suggests that it could be a potential diagnostic and therapeutic target for AS.