A process for the preparation of a quaternary N-alkyl morphin or morphinan alkaloid derivative of general formula a or b: wherein A is -C -, -C -, -C(=CH 2)-, or -CHA 1 -, A 1 is hydroxy, alkoxy, or acyloxy, wherein the alkyl group may be a straight or branched chain, or cyclic alkyl group, including allyl and benzyl, R 1 is hydrocarbyl or substituted hydrocarbyl, R 2 is hydrocarbyl or substituted hydrocarbyl, preferably selected from substituted or unsubstituted, saturated or unsaturated moieties of from 1 to 8 carbons; X - is an anion, Y is hydrogen, hydroxy, alkoxy, acyloxy, OTHP, -OBn, -OBz, -OBs, -OTs, -OMs, or -OSiR 3, wherein each R is independently hydrocarbyl, wherein the alkyl group may be a straight or branched chain, or cyclic alkyl group, including allyl and benzyl, starting from the tertiary N-alkyl morphin or morphinan alkaloid of general formula a or b wherein Z is hydroxy, alkoxy, acyloxy, OTHP, -OBn, -OBz, -OBs, -OTs, OMs, or -OSiR 3, wherein each R is independently hydrocarbyl, wherein the alkyl group may be a straight or branched chain, or cyclic alkyl group, including allyl and benzyl, via the intermediate zwitterion of formula a or b comprising the steps of: a) adding an alkylating agent to the compound of formula a or b in presence of an aprotic, dipolar solvent to obtain a reaction mixture; b) adding a nucleophilic nitrogen, phosphor or sulfur containing base to the reaction mixture to obtain the intermediate zwitterion of formula a or b in suspended or dissolved form; c) adding a solvent comprising alcohol and/or water to the product mixture thereby precipitating the compound of formula a or b; d) separating the precipitated compound of formula a or b from the remaining mixture; and e) suspending the intermediate zwitterion a or b in water and adding a compound of formula HX to produce the product of formula a or b. A is -C -, -C -, -C(=CH 2)-, or -CHA 1 -, A 1 is hydroxy, alkoxy, or acyloxy, wherein the alkyl group may be a straight or branched chain, or cyclic alkyl group, including allyl and benzyl, R 1 is hydrocarbyl or substituted hydrocarbyl, R 2 is hydrocarbyl or substituted hydrocarbyl, preferably selected from substituted or unsubstituted, saturated or unsaturated moieties of from 1 to 8 carbons; X - is an anion, Y is hydrogen, hydroxy, alkoxy, acyloxy, OTHP, -OBn, -OBz, -OBs, -OTs, -OMs, or -OSiR 3, wherein each R is independently hydrocarbyl, wherein the alkyl group may be a straight or branched chain, or cyclic alkyl group, including allyl and benzyl, a) adding an alkylating agent to the compound of formula a or b in presence of an aprotic, dipolar solvent to obtain a reaction mixture; b) adding a nucleophilic nitrogen, phosphor or sulfur containing base to the reaction mixture to obtain the intermediate zwitterion of formula a or b in suspended or dissolved form; c) adding a solvent comprising alcohol and/or water to the product mixture thereby precipitating the compound of formula a or b; d) separating the precipitated compound of formula a or b from the remaining mixture; and e) suspending the intermediate zwitterion a or b in water and adding a compound of formula HX to produce the product of formula a or b.