The tetrahedron equation is a three-dimensional generalization of the Yang-Baxter equation. Its solutions define integrable three-dimensional lattice models of statistical mechanics and quantum field theory. Their integrability is not related to the size of the lattice, therefore the same solution of the tetrahedron equation defines different integrable models for different finite periodic cubic lattices. Obviously, any such three-dimensional model can be viewed as a two-dimensional integrable model on a square lattice, where the additional third dimension is treated as an internal degree of freedom. Therefore every solution of the tetrahedron equation provides an infinite sequence of integrable 2d models differing by the size of this 'hidden third dimension'. In this paper, we construct a new solution of the tetrahedron equation, which provides in this way the two-dimensional solvable models related to finite-dimensional highest weight representations for all quantum affine algebra , where the rank n coincides with the size of the hidden dimension. These models are related to an anisotropic deformation of the sl(n)-invariant Heisenberg magnets. They were extensively studied for a long time, but the hidden 3d structure was hitherto unknown. Our results lead to a remarkable exact 'rank-size' duality relation for the nested Bethe Ansatz solution for these models. Note also that the above solution of the tetrahedron equation arises in the quantization of the 'resonant three-wave scattering' model, which is a well-known integrable classical system in 2 + 1 dimensions. © 2006 IOP Publishing Ltd.