Spider silk fibers are produced from soluble proteins (spidroins) under ambient conditions in a complex but poorly understood process. Spidroins are highly repetitive in sequence but capped by nonrepetitive N- and C-terminal domains (NT and CT) that are suggested to regulate fiber conversion in similar manners. By using ion selective microelectrodes we found that the pH gradient in the silk gland is much broader than previously known. Surprisingly, the terminal domains respond in opposite ways when pH is decreased from 7 to 5: Urea denaturation and temperature stability assays show that NT dimers get significantly stabilized and then lock the spidroins into multimers, whereas CT on the other hand is destabilized and unfolds into ThT-positive β-sheet amyloid fibrils, which can trigger fiber formation. There is a high carbon dioxide pressure (pCO2) in distal parts of the gland, and a CO2 analogue interacts with buried regions in CT as determined by nuclear magnetic resonance (NMR) spectroscopy. Activity staining of histological sections and inhibition experiments reveal that the pH gradient is created by carbonic anhydrase. Carbonic anhydrase activity emerges in the same region of the gland as the opposite effects on NT and CT stability occur. These synchronous events suggest a novel CO2 and proton-dependent lock and trigger mechanism of spider silk formation.