We develop a variational principle between mean dimension theory and rate distortion theory. We consider a minimax problem about the rate distortion dimension with respect to two variables (metrics and measures). We prove that the minimax value is equal to the mean dimension for a dynamical system with the marker property. The proof exhibits a new combination of ergodic theory, rate distortion theory and geometric measure theory. Along the way of the proof, we also show that if a dynamical system has the marker property then it has a metric for which the upper metric mean dimension is equal to the mean dimension.