Abstract A variational method that can provably construct 3D quasi-isometric mappings between domains of a complex shape is introduced. A local maximum principle for polyconvex mesh element distortion measures is formulated. It allows us to control the invertibility and distortion bounds for non-simplicial elements in the minimization process. A simple and efficient technique for construction of boundary orthogonal meshes suggested in Garanzha (2000) is applied to the construction of hexahedral meshes and thick prismatic mesh layers around complex shapes. The mesh untangling technique, which is a generalization of the penalty method suggested in Garanzha and Kaporin (1999), is verified on a wide set of challenging test problems. Another untangling technique based on theoretical ideas from Ivanenko (1997) is implemented and tested. It provably constructs admissible meshes using a finite number of minimization steps. A minimization technique for the mesh distortion functional is described. The approach is based on the global gradient search technique with preconditioning and domain decomposition for local mesh optimization and untangling. Application areas for explicit and implicit minimization methods are evaluated.