Surprisingly little is actually known about hiccups. The name itself is onomatopoeic, mimicking the abrupt rush of air into the lungs causes the epiglottis to close. In medicine, hiccups is known as synchronous diaphragmatic flutter (SDF), or singultus.
But, basically, when you hiccup, your diaphragm (and the muscles near to it) convulse, causing you to briefly gulp air. This causes the glottis to slam shut which makes the "hic" noise. Once the hiccups start, unless you can stop them right away they usually go on for what seems like forever. The record for longest bout of hiccups is 68 years(1).