Background: Pulmonary arterial hypertension (PAH) is a rare disorder leading to premature death. Rare genetic variants contribute to disease etiology but the contribution of common genetic variation to disease risk and outcome remains poorly characterized. Methods: We performed two separate genome-wide association studies of PAH using data across 11,744 European-ancestry individuals (including 2,085 patients), one with genotypes from 5,895 whole genome sequences and another with genotyping array data from 5,849 further samples. Cross-validation of loci reaching genome-wide significance was sought by meta-analysis. We functionally annotated associated variants and tested associations with duration of survival. Findings: A locus at HLA-DPA1/DPB1 within the class II major histocompatibility (MHC) region and a second near SOX17 were significantly associated with PAH. The SOX17 locus contained two independent signals associated with PAH. Functional and epigenomic data indicate that the risk variants near SOX17 alter gene regulation via an enhancer active in endothelial cells. PAH risk variants determined haplotype-specific enhancer activity and CRISPR-inhibition of the enhancer reduced SOX17 expression. Analysis of median survival showed that PAH patients with two copies of the HLA-DPA1/DPB1 risk variant had a two-fold difference (>16 years versus 8 years), compared to patients homozygous for the alternative allele. Interpretation: We have found that common genetic variation at loci in HLA-DPA1/DPB1 and an enhancer near SOX17 are associated with PAH. Impairment of Sox17 function may be more common in PAH than suggested by rare mutations in SOX17. Allelic variation at HLA-DPB1 stratifies PAH patients for survival following diagnosis, with implications for future therapeutic trial design. Funding: UK NIHR, BHF, UK MRC, Dinosaur Trust, NIH/NHLBI, ERS, EMBO, Wellcome Trust, EU, AHA, ACClinPharm, Netherlands CVRI, Dutch Heart Foundation, Dutch Federation of UMC, Netherlands OHRD and RNAS, German DFG, German BMBF, APH Paris, Inserm, Universite Paris-Sud, and French ANR.