Dehydrogenative annulation under oxidizing reagent-free conditions is an ideal strategy to construct cyclic structures. Reported herein is an unprecedented synthesis of pyrrolidine and tetrahydropyridine derivatives through electrochemical dehydrogenative annulation of N-allyl amides with 1,3-dicarbonyl compounds. The electrolytic method employs an organic redox catalyst, which obviates the need for oxidizing reagents and transition-metal catalysts. In these reactions, the N-allyl amides serve as a four-atom donor to react with dimethyl malonate to give pyrrolidines by a (4+1) annulation, or with β-ketoesters to afford tetrahydropyridine derivatives by a (4+2) annulation.