A versatile approach to align anisotropic mesophases in the presence of magnetic nanoparticles in response to an external magnetic field is demonstrated. A memory effect is shown, as the alignment of the nanoparticles, the mesophase, and the overall birefringence can be stored, erased, and rewritten reversibly by changing the temperature and the direction of the external magnetic field.