Addition of 5-alkylaminopenta-2,4-dienals onto N-acyliminium ions, generated in situ from α-hydroxycarbamates derived from pyrrolidine or piperidine, in the presence of zinc triflate, followed by dehydrative cyclization, allowed the formation of pyridinium salts substituted at their 3-position by a five- or six-membered nitrogen heterocycle. Subsequent N-dealkylation of the pyridinium moiety and deprotection of the secondary amine or reduction of the carbamate function led to (±)-nicotine and analogs.