We report on a nonlinear way to control and tune the dielectric environment of photonic crystal microcavities exploiting the local heating induced by near-field laser excitation at different excitation powers. The temperature gradient due to the optical absorption results in an index of refraction gradient which modifies the dielectric surroundings of the cavity and shifts the optical modes. Reversible tuning can be obtained either by changing the excitation power density or by exciting in different points of the photonic crystal microcavity. © 2008 American Institute of Physics