The physics of the intracluster medium, in particular the values for the thermal conductivity and the viscosity are largely unknown and subject to an ongoing debate. Here, we study the effect of viscosity on the thermal state of the intracluster medium using three-dimensional cosmological simulations of structure formation. It is shown that viscosity, provided it is not too far off from the unmagnetised Spitzer value, has a significant effect on cluster profiles. In particular, it aids in heating the cool cores of clusters. The central cooling time of the most massive clusters in our simulation is increased by more than an order of magnitude. In large clusters, viscous heating may help to establish an entropy floor and to prevent a cooling catastrophe.