It's possibly the cruelest joke a brain can play: One minute you're devouring a delicious ice cream sundae in delight, the next you're holding a palm to your forehead in excruciating pain.

And until now, researchers could never quite understand what causes it.

While previous studies have found that people who suffer from migraines are actually more likely to get brain freeze, a new study links brain freeze and other headache types to changes in brain blood flow.

In the new study, a group of researchers took 13 healthy volunteers and had them sip ice water through a straw right up against the roof of their mouth. The volunteers were then told to raise their hands when they felt the familiar brain freeze come on, and raise them again once it disappeared.

The researchers from Harvard Medical School evaluated cerebral blood flow velocity (CBFV) in the middle and anterior cerebral arteries while the 13 volunteers consumed the ice water.

CBFV, heart rate, and blood pressure were analyzed before pain, during pain, and after pain.

Results from the study indicate that the sudden headache is triggered by an abrupt increase in blood flow in the anterior cerebral artery.

Blood flow increased significantly in the anterior cerebral artery when the volunteers felt pain. This artery feeds the brain's frontal lobe (remember the palm to your forehead?). The artery then constricted as the volunteers' pain subsided.

"We're not sure what might be causing the pain itself," lead author, Jorge Serrador said.

One possible reason is the increase in pressure that's associated with the influx of blood flow to the frontal lobe, he said.