Changes in neuronal activity create local and transient changes in energy demands at synapses. Here we discover a metabolic compartment that forms in vivo near synapses to meet local energy demands and support synaptic function in Caenorhabditis elegans neurons. Under conditions of energy stress, glycolytic enzymes redistribute from a diffuse localization in the cytoplasm to a punctate localization adjacent to synapses. Glycolytic enzymes colocalize, suggesting the ad hoc formation of a glycolysis compartment, or a "glycolytic metabolon," that can maintain local levels of ATP. Local formation of the glycolytic metabolon is dependent on presynaptic scaffolding proteins, and disruption of the glycolytic metabolon blocks the synaptic vesicle cycle, impairs synaptic recovery, and affects locomotion. Our studies indicate that under energy stress conditions, energy demands in C. elegans synapses are met locally through the assembly of a glycolytic metabolon to sustain synaptic function and behavior. VIDEO ABSTRACT.