Objective: The objective of this study is to evaluate the efficacy and safety of tofacitinib in patients with ankylosing spondylitis (AS). Methods: In this randomised, double-blind, placebo-controlled study, patients with active AS aged between 18 and 60 years who fulfilled the modified New York criteria for AS and had inadequate response or intolerance to non-steroidal anti-inflammatory drugs were enrolled. Patients were randomised to receive either tofacitinib 5 mg twice daily or placebo for 12 weeks. The primary endpoint was Assessment of Spondyloarthritis International Society ≥20% improvement (ASAS20), and the secondary endpoints included Assessment of Spondyloarthritis International Society ≥40% improvement response, mean change from baseline in Bath Ankylosing Spondylitis Disease Activity Index (BASDAI), Ankylosing Spondylitis Disease Activity Score–C-reactive protein (ASDAS–CRP), Bath Ankylosing Spondylitis Metrology Index (BASMI), Bath Ankylosing Spondylitis Functional Index (BASFI), Maastricht Ankylosing Spondylitis Enthesitis Score (MASES), erythrocyte sedimentation rate (ESR), C-reactive protein (CRP), serum tumour necrosis factor alpha (TNF-α) and interleukin 17A (IL-17A) levels. Safety assessment was done throughout the study period. Results: Forty-eight patients were included in the study and received either tofacitinib ( n = 25) or placebo ( n = 23). The ASAS20 response was significantly higher in the tofacitinib group compared with placebo (68% vs 13%, P < .001). Significant improvement was also seen in secondary endpoints, including mean change in BASDAI ( P < .001), ASDAS–CRP ( P < .001), BASMI ( P = .003), BASFI ( P = .001), ESR ( P = .002), CRP ( P = .003), serum TNF-α ( P = .007) and IL-17A levels ( P <.001). There was no significant difference in MASES ( P = .7). Both groups had similar infection rates. Conclusions: In patients with active AS, tofacitinib was effective in reducing disease activity measures compared with placebo.