In most Gram-negative pathogens, the hydrolysis of UDP-2,3-diacylglucosamine to generate lipid X in lipid A biosynthesis is catalysed by the membrane-associated enzyme LpxH. We report the crystal structure of LpxH in complex with its product, lipid X, unveiling a unique insertion lid above the conserved architecture of calcineurin-like phosphoesterases. This structure reveals elaborate interactions surrounding lipid X and provides molecular insights into the substrate selectivity, catalysis and inhibition of LpxH.