When you hiccup, your diaphragm involuntarily contracts. (The diaphragm is a dome-shaped muscle that separates the chest cavity from the abdomen. It plays an extremely important role in breathing.)
This contraction of the diaphragm then causes an immediate and brief closure of the vocal cords, which produces the characteristic sound of a hiccup. What actually causes the hiccup is difficult to say - in most instances, there is no obvious cause.
Attacks of the hiccups seem to be associated with a few different things: eating or drinking too fast; being nervous or excited; or having irritation in the stomach and/or throat.
In some extremely rare cases, the underlying cause of hiccups can be pleurisy (inflammation of the membrane lining of the lungs and chest cavity), pneumonia, certain disorders of the stomach or esophagus, pancreatitis, alcoholism, or hepatitis. Any one of these conditions can cause irritation of the diaphragm or of the phrenic nerves that supply the diaphragm - it's the irritation that causes the hiccups.
Still, the cause of most attacks of the hiccups remains a mystery.