The transient receptor potential ion channel TRPA1 is expressed by primary afferent nerve fibres, in which it functions as a low-threshold sensor for structurally diverse electrophilic irritants, including small volatile environmental toxicants and endogenous algogenic lipids. TRPA1 is also a 'receptor-operated' channel whose activation downstream of metabotropic receptors elicits inflammatory pain or itch, making it an attractive target for novel analgesic therapies. However, the mechanisms by which TRPA1 recognizes and responds to electrophiles or cytoplasmic second messengers remain unknown. Here we use strutural studies and electrophysiology to show that electrophiles act through a two-step process in which modification of a highly reactive cysteine residue (C621) promotes reorientation of a cytoplasmic loop to enhance nucleophilicity and modification of a nearby cysteine (C665), thereby stabilizing the loop in an activating configuration. These actions modulate two restrictions controlling ion permeation, including widening of the selectivity filter to enhance calcium permeability and opening of a canonical gate at the cytoplasmic end of the pore. We propose a model to explain functional coupling between electrophile action and these control points. We also characterize a calcium-binding pocket that is highly conserved across TRP channel subtypes and accounts for all aspects of calcium-dependent TRPA1 regulation, including potentiation, desensitization and activation by metabotropic receptors. These findings provide a structural framework for understanding how a broad-spectrum irritant receptor is controlled by endogenous and exogenous agents that elicit or exacerbate pain and itch.