Three-dimensional imaging at high-spatiotemporal resolutions and over large penetration depths is key for unmasking the dynamics and structural organization of complex biological systems. However, the need to axially shift the focus, with consequent limitations in imaging speed, and signal degradation at large depths due to scattering effects, makes this task challenging. Here, we present a novel approach in 2-photon excitation microscopy that allows fast volumetric imaging and enhanced signal-to-background (S/B) in thick tissue. Our technique is based on ultrafast beam shaping at each pixel by means of an acoustic optofluidic lens. Shaping the excitation beam with different phase profiles enables both high-speed axial focus shifting, for continuous volumetric imaging, and controlled aberrated imaging, advantageous for out-of-focus background removal. We provide a theoretical description of our approach, and demonstrate volumetric imaging of neuronal cells from a mouse brain slice with enhancements in S/B up to a factor of 10 over a depth of 600 μm.