The anal glands are two sacs embedded in the anus of dogs and cats. In a cat they are very small when full, perhaps the size of a pea, while in the dog they may be reach the size of a small potato.
The anal glands produce a fluid that is normally a light liquid of a yellow/green colour and of a very characteristic offensive odour. The glands have a very small opening to the anus. The gland is expressed (squeezed out) slightly when the animal has a bowel movement, or if it experiences sudden fright. The anal glands do not have a real function that we know of; they are remnants of evolution where they may have been used as a way of marking territory.
Most dogs do not need any intervention with their anal glands. They express the fluid at regular intervals during stool. However, some dogs produce an excess of fluid and cannot remove it on their own. When the anal glands are full it causes itching and may trigger a rash at the base of the tail and lower back. In extreme cases it may cause gastrointestinal discomfort, including vomiting and constipation. In those cases the anal gland must be manually expressed or its contents become thick and infected, resulting in an abscess that could burst. Cats may suffer impaction of the anal glands and are more likely to experience vomiting as a result.
The treatment of anal gland disease may involve antibiotics, frequent manual emptying of the glands, infusion of medication into the glands, or surgical removal of the glands themselves.
(see also Scent of a Dog for more on this topic.)