The use of spatial light modulators (SLMs) for two-photon laser microscopy is described. SLM phase modulation can be used to generate nearly any spatiotemporal pattern of light, enabling simultaneous illumination of any number of selected regions of interest. We take advantage of this flexibility to perform fast two-photon imaging or uncaging experiments on dendritic spines and neocortical neurons. By operating in the spatial Fourier plane, an SLM can effectively mimic any arbitrary optical transfer function and thus replace, in software, many of the functions provided by hardware in standard microscopes, such as focusing, magnification, and aberration correction.