δ-Lactams and 1-lactams present important structural moieties which are found in many pharmaceuticals, targeting a wide array of diseases. Starting from commercially available esters, we developed a facile method for the synthesis of 3-substituted pyrrolidin-2-ones and piperidin-2-ones. To this end, the ester is a-alkylated with 2-azidoethyl trifluoromethanesulfonate or 2-azidopropyl trifluoromethanesulfonate, followed by azide reduction and ring closure. A continuous flow protocol was developed for the azide - amine transformation but a batch protocol is available as well.