Rhizobia induce nodule formation on legume roots and differentiate into bacteroids, which catabolize plant-derived dicarboxylates to reduce atmospheric N2 into ammonia. Despite the agricultural importance of this symbiosis, the mechanisms that govern carbon and nitrogen allocation in bacteroids and promote ammonia secretion to the plant are largely unknown. Using a metabolic model derived from genome-scale datasets, we show that carbon polymer synthesis and alanine secretion by bacteroids facilitate redox balance in microaerobic nodules. Catabolism of dicarboxylates induces not only a higher oxygen demand but also a higher NADH/NAD+ ratio than sugars. Modeling and 13C metabolic flux analysis indicate that oxygen limitation restricts the decarboxylating arm of the tricarboxylic acid cycle, which limits ammonia assimilation into glutamate. By tightly controlling oxygen supply and providing dicarboxylates as the energy and electron source donors for N2 fixation, legumes promote ammonia secretion by bacteroids. This is a defining feature of rhizobium-legume symbioses.