In optical imaging, achieving high resolution often comes at the expense of a shallow depth of field. This means that when using a standard microscope, any minor movement of the object along the optical axis can cause the image to become blurry. To address this issue, we exploit inverse design techniques to optimize a phase mask which, when inserted into a standard microscope, extends the depth of field by a factor of approximately four without compromising the microscope's resolution. Differentiable Fourier optics simulations allow us to rapidly iterate toward an optimized design in a hybrid fashion, starting with gradient-free Bayesian optimization and proceeding to a local gradient-based optimization. To fabricate the device, a commercial two-photon 3D laser nanoprinter is used, in combination with a two-step precompensation routine, providing high fabrication speed and much better than subwavelength accuracy. We find excellent agreement between our numerical predictions and the measurements upon integrating the phase mask into a microscope and optically characterizing selected samples. The phase mask enables us to conduct simultaneous multiplane imaging of objects separated by distances that cannot be achieved with the original microscope.