Inorganic phosphate (Pi) is a fundamental macronutrient for all living organisms, the homeostasis of which is critical for numerous biological activities1–3. As the only known human Pi exporter to date, XPR1 has an indispensable role in cellular Pi homeostasis4,5. Dysfunction of XPR1 is associated with neurodegenerative disease6–8. However, the mechanisms underpinning XPR1-mediated Pi efflux and regulation by the intracellular inositol polyphosphate (InsPP) sensor SPX domain remain poorly understood. Here we present cryo-electron microscopy structures of human XPR1 in Pi-bound closed, open and InsP6-bound forms, revealing the structural basis for XPR1 gating and regulation by InsPPs. XPR1 consists of an N-terminal SPX domain, a dimer-formation core domain and a Pi transport domain. Within the transport domain, three basic clusters are responsible for Pi binding and transport, and a conserved W573 acts as a molecular switch for gating. In addition, the SPX domain binds to InsP6 and facilitates Pi efflux by liberating the C-terminal loop that limits Pi entry. This study provides a conceptual framework for the mechanistic understanding of Pi homeostasis by XPR1 homologues in fungi, plants and animals.