Transition metal ions have, by definition, at least one partly filled d orbital (eg:3d). When in a solution, the positive charge of the transition metal ions can cause the lone elctron pairs of other molecules in the solution (such as water) to be attracted to the transition metal ion, leading to the formation of dative coordinate bond between the metal ion and the ligand - the name used to describe the molecule bonding the metal ion.
The bonding of the ligand molecules to the metal ion causes the energy level of some of the valence d orbitals to be increased, resulting in an energy gap between different valence d orbitals. Electrons in the lower level of d orbitals can absorb visible frequencies of light (which correspond to the energy gap between the orbitals by E=hv) to become excited and move to the higher energy level. This causes the solution to appear the complementary colour to that of the frequency of light absorbed.