Pelletierine, a proposed building block of Lycopodium alkaloids (LAs), was demonstrated to be synthesized via the non-enzymatic Mannich-like condensation of Δ1-piperideine and 3-oxoglutaric acid produced by two new type III PKSs (HsPKS4 and PcPKS1) characterized from Huperzia serrata and Phlegmariurus cryptomerianus, respectively. The findings provide new insights for further understanding the biosynthesis of LAs such as huperzine A.