The objective of this case-control study was to evaluate the role of four single-nucleotide polymorphisms in the ERAP1 (rs2287987, rs30187, rs27044) and ERAP2 (rs2248374) genes and their haplotypes in predicting the risk for ankylosing spondylitis (AS) on a well-defined Polish population. Our study confirmed the strong association between the HLA-B*27 allele and the disease. For all tested ERAP1 SNPs we found significant differences in the minor allele and genotype distribution between patients and controls. The strongest association with AS was observed for rs30187. The minor T allele and homozygous TT genotype of this SNP significantly increased disease risk (OR = 1.56, 95%CI = 1.22–1.99, p = 0.0004 and OR = 2.52, 95%CI = 1.50–4.25, p = 0.001, respectively). In the case of rs2287987, minor C allele exerted a protective effect (OR = 0.64, 95%CI = 0.46–0.88, p = 0.008). In contrast to ERAP1, we observed no effect of rs2248374 in ERAP2 on the disease. We also carried out ERAP1-ERAP2 haplotype analysis to demonstrate a possible association of both genes with AS. Results showed that the haplotype H4, containing ERAP1 SNPs associated with high enzymatic activity, together with the presence of ERAP2 expression, significantly increased the risk of AS (OR = 1.97, 95% CI = 1.21–3.21, pcorr = 0.048). By contrast, the haplotype H5 coding for low activity of ERAP1 and the lack of ERAP2 expression was strongly protective (OR = 0.41, 95% CI = 0.23–0.72, pcorr = 0.008).