The photochemical rearrangement of N-activated lactams enables their ring contraction concomitant with the migration of a carbon onto a nitrogen atom. When coupled with the Beckmann rearrangement, this photochemical ring contraction converts cycloalkanones into N-heterocycles in a few steps and in a stereospecific manner. To showcase the method, we performed an efficient formal synthesis of (-)-gephyrotoxin 287C.