Kelvin stated that gravitational energy released due to contraction was responsible for the energy radiated in the stars. Although the theory was wrong, was the assumption practically right? If it's right, how does contraction take place?
It is correct. Contracting stars heat up due to their own contraction. This justifies the initial temperature raise in a star, before fusion begins in earnest.
Kelvin was not 100% wrong, it's just that fusion, over the life time of the star, makes much, much more energy than contraction. The collapse heats up the star at the very beginning, then fusion takes over and makes essentially all the heat you observe.
This is also true of gas giant planets. Even a tiny amount of contraction may raise their temperature measurably. E.g., Jupiter radiates more energy than it receives from the Sun - this is due to contraction, at a rate of 2 cm / year (diameter).
TLDR: Gravitational energy becomes heat.
Gravitational contraction will always release gravitational potential energy. In most systems, where this happens slowly, you can apply the virial theorem to say that half the released energy is radiated and half is used to heat the contracting gas.
The real question is whether the release of gravitational PE is significant compared with other sources. In most stars it is not. Nuclear fusion is responsible for extending their lives way beyond the Kelvin-Helmholtz timescale - the amount of GPE divided by their luminosity.
In some stars GPE is hardly released at all though. The capability to contract depends on the behaviour of gas's pressure as a function of temperature. If pressure is independent of temperature then no contraction of an object is possible even as it radiates away its energy and even if it has no other energy sources.
This is the case for white dwarfs supported by electron degeneracy pressure. They cannot contract further and will simply cool down at constant radius.
Jupiter is an interesting intermediate case. Yes it is contracting, but not at the rate you would expect for a perfect gas. Eventually, its contraction will slow right down and it will just cool.
In addition to the answers by Florin and Rob, I'd like to point out that the gravitational energy in the end dominates over all other sources, like fusion, at least for massive stars.
When a massive star eventually collapses to a neutron star, the gravitational pressure is so strong that protons and electrons are pressed into neutrons and all heavy nuclei are destroyed. In other words, the energy gained by fusion was merely a credit payed back with huge interest.
The situation is even more dramatic when the star collapses to a black hole. Such objects release an energy of $\epsilon M c^2$ with efficiency $\epsilon\sim0.1$ depending on the details (e.g. the spin of the black hole). This is far more than the $\epsilon<0.01$ from Hydrogen fusion and by far the most efficient natural energy source. The energy emitted from the formation of supermassive black holes equals (approximately) the binding energy of their host galaxies.