You should just just be able to allocate a texture with an internal format of GL_DEPTH_COMPONENT, and call glCopyTexSubImage2D to copy the contents of the depth buffer into that texture. After that, you can render a fullscreen quad with the texture, or whatever else you want...
This looks like exactly what I was thinking. However, I cannot find the proper code for it, and I fear guessing it from scratch will end in utter failure (I am not a veteran). Is there an example or perhaps even a tutorial of this exact method somewhere?
However, unless you are restricted to an ancient version of OpenGL, I would recommend using an FBO (Frame Buffer Object), to render the depth buffer directly to a texture in the first place. Or even a shader, to render the z coordinate into the colour buffer, and save having to render multiple passes at all.
Partly due to my not being veteran, but also because of a long and boring story about what I'm doing (which I'll spare you), I would like to at least try without FBOs or shaders first, if there is a way?