HAE is primarily caused by mutations in the SERPING1 gene, which leads to a deficiency or dysfunction of the C1 inhibitor protein. This protein plays a critical role in regulating the complement and contact systems, which are part of the body's immune response. A lack of functional C1 inhibitor results in excessive production of bradykinin, a peptide that increases vascular permeability and causes swelling.