Plants synthesize numerous alkaloids that mimic animal neurotransmitters(1). The diversity of alkaloid structures is achieved through the generation and tailoring of unique carbon scaffolds(2,3), yet many neuroactive alkaloids belong to a scaffold class for which no biosynthetic route or enzyme catalyst is known. By studying highly coordinated, tissue-specific gene expression in plants that produce neuroactive Lycopodium alkaloids(4), we identified an unexpected enzyme class for alkaloid biosynthesis: neofunctionalized alpha-carbonic anhydrases (CAHs). We show that three CAH-like (CAL) proteins are required in the biosynthetic route to a key precursor of the Lycopodium alkaloids by catalysing a stereospecific Mannich-like condensation and subsequent bicyclic scaffold generation. Also, we describe a series of scaffold tailoring steps that generate the optimized acetylcholinesterase inhibition activity of huperzine A(5). Our findings suggest a broader involvement of CAH-like enzymes in specialized metabolism and demonstrate how successive scaffold tailoring can drive potency against a neurological protein target. CI - (c) 2023. The Author(s).