The aim of the present study was to determine the prevalence of human leukocyte antigen HLA-B27 in Moroccan healthy controls and in patients with ankylosing spondylitis (AS), and to analyze the correlation between HLA-B27 and AS in Moroccan patients. The prevalence of HLA-B27 was determined by evaluating the number of HLA-B27-positive samples in 128 healthy subjects and in 53 patients diagnosed with AS according to the ESSG and AMOR criteria. HLA-B27 was determined by the polymerase chain reaction using sequence-specific primers. Multivariate analysis of our data (HLA-B27, age, sex, and family history) for AS and healthy controls was performed by multiple correspondence analysis (MCA). The frequency of HLA-B27 was significantly greater in AS patients (45.3 %) than in healthy controls (4.7 %) [p < 0.0001, OR 16.8, and CI 95 % (5.83-51.03)]. In addition, HLA-B27 was more common in male patients than in female ones (p < 0.05). 100 % of the AS patients reported a family history of AS, whereas only 20 % of the healthy controls reported a family history of AS. The graphical interpretation of MCA showed a significant relation between the presence of HLA-B27 and AS. This study strengthens the link between HLA-B27 and AS and represents a very valuable informative diagnostic tool, especially in regard to male patients who have a family history of AS.