In this paper a computational fluid dynamics (CFD) approach for solving elastohydrodynamic lubrication using the freely available package OPENFOAM is introduced. The full Navier–Stokes equations are solved, which enables the entire flow domain to be modeled and all gradients inside the lubricated contact to be resolved. The phenomenon of cavitation is taken into account by employing a homogenous equilibrium cavitation model, which maintains a specified cavitation pressure inside the cavitating region. The energy equation used considers the effects of heat conduction and convection, viscous heating, and the heat of evaporation. The developed method has been applied to a series of cases of lubricated metal-on-metal line contact with an entrainment velocity of , viscosities , and slide-to-roll ratios under both thermal and isothermal conditions. The isothermal results are compared to the Reynolds theory and most results agree very well. Only the high-viscosity pure rolling case shows small differences. The combined effects of temperature, pressure, and shear-thinning are studied for the thermal cases. A temperature-induced shear band occurs in the case of sliding combined with very large viscosity compared to the isothermal case, which results in significant pressure variations across the thickness of the film. The impact of temperature on the friction force is discussed, showing differences of up to compared to the isothermal case. The developed method is capable of giving new insights into the physics of elastohydrodynamic lubrication, especially in cases where the usual assumptions of the Reynolds theory break down.