Context. Solutions of the magnetohydrostatic (MHS) equations are very important for modelling astrophysical plasmas, such as the coronae of magnetized stars. Realistic models should be three-dimensional, i.e., should not have any spatial symmetries, but finding three-dimensional solutions of the MHS equations is a formidable task. Aims. We present a general theoretical framework for calculating three-dimensional MHS solutions outside massive rigidly rotating central bodies, together with example solutions. A possible future application is to model the closed field region of the coronae of fast-rotating stars. Methods. As a first step, we present in this paper the theory and solutions for the case of a massive rigidly rotating magnetized cylinder, but the theory can easily be extended to other geometries, We assume that the solutions are stationary in the co-rotating frame of reference. To simplify the MHS equations, we use a special form for the current density, which leads to a single linear partial differential equation for a pseudo-potential U. The magnetic field can be derived from U by differentiation. The plasma density, pressure, and temperature are also part of the solution. Results. We derive the fundamental equation for the pseudo-potential both in coordinate independent form and in cylindrical coordinates. We present numerical example solutions for the case of cylindrical coordinates.