Many galaxy clusters pose a ‘cooling-flow problem’, where the observed X-ray emission from their cores is not accompanied by enough cold gas or star formation. A continuous energy source is required to balance the cooling rate over the whole core volume. We address the feasibility of a gravitational heating mechanism, utilizing the gravitational energy released by the gas that streams into the potential well of the cluster dark matter halo. We focus here on a specific form of gravitational heating in which the energy is transferred to the medium thorough the drag exerted on inflowing gas clumps. Using spherisymmetric hydro simulations with a subgrid representation of these clumps, we confirm our earlier estimates that in haloes ≥1013 M⊙ the gravitational heating is more efficient than the cooling everywhere. The worry was that this could overheat the core and generate an instability that might push it away from equilibrium. However, we find that the overheating does not change the global halo properties, and that convection can stabilize the cluster by carrying energy away from the overheated core. In a typical rich cluster of 1014-15 M⊙, with ∼5 per cent of the accreted baryons in gas clumps of ∼108 M⊙, we derive upper and lower limits for the temperature and entropy profiles and show that they are consistent with those observed in cool-core clusters. We predict the density and mass of cold gas and the level of turbulence driven by the clump accretion. We conclude that gravitational heating is a feasible mechanism for preventing cooling flows in clusters.