As the origin of door-god, there are also some legends and popular stories. After Xuanwu Gate Incident, Li Shimin (Prince of Qin, Emperor Taizong in Tang dynasty later) killed all families of his brothers: Li Jiancheng(Crown Prince) and Li Yuanji (Prince of Qi), even babies. At night, Li Shimin often heard bricks and tiles throwing, crying and yelling when sleeping, restless at whole nights. He often had nightmares, dreaming his brothers of coming to kill him with ghosts and monsters and quite feared, sleepless. Therefore, he ordered his two generals: Qin Shubao and Yuchi Jingde to guard with weapons, and then he can sleep at ease. However, the guarding without sleep for long time made these two generals sick, so Li Shimin ordered drawing them on the pictures, stamping on the door to frighten ghosts and devils. This is just the origin of door-god.
Another is recorded in Journey to the West (Pilgrimage to the West): an old dragon of Jing-river bet with a fortune teller, making mistake in heaven. The Jade Emperor sent Wei Zheng to oversee the execution of the old dragon. One day before that, old dragon begged Li Shimin to intercede for him and Li promised it. One the second day, Li asked Weizheng to play the game of go in the palace. Wei dozed off and killed the old dragon in the dream. The dragon hated Li of breaking his promise, and always made troubles in the palace as ghosts. Wei sent Qin Shubao and Yuchi Jingde to guard with weapons, standing before the door. Old dragon dare not make it. Li asked drawers to draw them, stamping their pictures on the door, also in effect. Therefore, such action also spreads in the folks. Qin Shubao and Yuchi Jingde become door-god.