What's the story behind the Hungry Ghost Festival?

There are many legends about Chinese Hungry Ghost Festival and the main three are as follows:

Chinese Folk Legend
According to the Chinese folk legend, the gate of hell is wide open on July 15 in Chinese calendar and ghosts would come out on this day. Those who are offered sacrifices come back to the hometown to accept the worship of descendants while Buddhist or Taoist rituals are held by the public to worship the lost spirits and ghosts to keep them from wandering around and harming the living beings.

Legend of Zhongyuan Festival by Taoism
The Ghost Festival is called Zhongyuan Festival by Taoism. Taoism believes the name of Zhongyuan Festival is originated from Northern Wei Dynasty (368-534). According to the ancient books, the lunar January 15 is the Lantern Festival, a blessing day of the Heaven King; the lunar July 15 is the Ghost Festival, a pardon day of the Hell King while the lunar October 15 is the Water Lantern Festival, a disaster relief day of the Water King. On lunar July 15, the birthday of Hell King, the hungry ghosts and imprisoned spirits are pardoned and released from the hell to accept the rituals and sacrifices for one month since July 1 in the mortal world, so as to motivate them to practice Taoism. Through the sacrifice ceremony and rites, Taoist followers assist the Hell King to release souls from purgatory early and keep them from causing troubles to the realm of the living. Therefore, the Taoists chant sutras, hold rituals and offer sacrifices to release the suffering spirits from purgatory, while the folk people worship the Hell King and their ancestors with rich sacrifices.

Buddhist Legend: Mulian Rescues His Mother
Yu Lan Pen Festival is what Buddhists call to the Chinese ghost festival. A Buddhist legend about the festival goes that, when Buddha Shakyamuni was still alive, one of his ten disciples named Mulian (Maudgalyayana) cultivated and got enlightenment, becoming an Arhat with miraculous powers. His parents died early before this. To repay the birth of his parents, he observed with the deva eyes and found his dead mother in the realm of hungry ghosts and she had no food and looked skinny. Maudgalyayana was sorrowful and he used the miraculous power to offer a bowl of rice to his mother. When she was about to eat, the food suddenly changed to ash. Extremely grieved, he came to Buddha Shakyamuni and told the Buddha what happened. The Buddha inspired him: ''your mother was guilty of many sins when she was alive, so she has to be a hungry ghost and suffer a lot. You cannot release her with your own strength but the power of monks in ten directions. Every year, all the monks cultivate together from April 15 to July 15 and on the last day, there must be many who get enlightenment. If you want to release your mother from the realm of hungry ghosts, you should offer all kinds of good vegetarian food to them, and this will be a good deed which can release your mother from the realm of hungry ghosts, benefit your parents in the last seven lifetimes and prolong their life if they are still alive.''

Maudgalyayana followed what the Buddha Shakyamuni said and released his mother from the sufferings. Later, a folk custom is formed according to the legend and gradually evolves from making offerings to monks to ghosts. In every lunar July, Chinese people would kill chickens and ducks, and burn incense and clothes to worship the hungry ghosts and dissolve their grievances, so that they no longer cause trouble to the mortal world. Over time, the Ghost Festival is formed.

Related Reading: 
→ Ghost Month
→ Can You Move House During Ghost Month?
→ Can You Get Married During Ghost Month?
→ Taboos to Avoid during Hungry Ghost Month

Chinese Calendar

SuMoTuWeThFrSa
25十六/16 26十七/17 27十八/18 28十九/19 29二十/20 1廿壹/21 2廿二/22
3廿三/23 4廿四/24 5廿五/25 6廿六/26 7廿七/27 8廿八/28 9廿九/29
二月 (Feb) 10初壹/1 11初二/2 12初三/3 13初四/4 14初五/5 15初六/6 16初七/7
17初八/8 18初九/9 19初十/10 20十壹/11 21十二/12 22十三/13 23十四/14
24十五/15 25十六/16 26十七/17 27十八/18 28十九/19 29二十/20 30廿壹/21
31廿二/22 1廿三/23 2廿四/24 3廿五/25 4廿六/26 5廿七/27 6廿八/28