The unexpected retroaldol-aldol reaction during O-alkylation of a β-hydroxy lactam was found to be highly dependent on the temperature and shows a remarkable solvent effect. In DMF, O-alkylation is faster than retroaldol-aldol rearrangement giving exclusively products with retention of configuration. In THF, O-alkylation is slower than rearrangement, giving selectively products with inversion of stereochemistry. In DMSO, a retroaldol reaction followed by fast intramolecular proton transfer occurs to give the ring-opened aldehyde.