A detergent molecule consists of a hydrophilic "head" and hydrophobic "tail". When a detergent substance is dissolved in water, electrically charged ions constitute its molecules, with charges concentrated in the molecular "heads". This is what assures the hydrophilic nature of the "heads", since polar molecules are in intensive interaction with this part of the detergent molecule. On the other hand, although the "tails" exhibit only weak interaction with water, a "tail" can cling to the solid bits of mud, lipid particles, etc. As a result, detergent molecules form a kind of a cocoon, enveloping mud or other alien substances, and preventing them from dissolving in water. After that, the particle covered by the detergent interacts with the water in a far more intensive fashion, and it can be separated from the surfaces with greater ease. Note that the hydrophilic "heads" of detergents carry negative charges, and therefore water molecules turn into atoms of hydrogen upon contact with detergent's "heads".