Liu Bingyi was born in 91 BC to Liu Jin, the son of then-Crown Prince Liu Ju, and his wife Consort Wang. As the grandson of the Crown Prince, Bingyi likely was born in Prince Ju's palace. That same year, however, disaster would strike. With conspirators accusing him of using witchcraft against his father Emperor Wu, Prince Ju was forced into a rebellion, which was defeated. Prince Ju committed suicide, and Bingyi's two uncles died with him, although it was not clear whether they also committed suicide or were killed by soldiers. Bingyi's great-grandmother Empress Wei also committed suicide, and his grandmother (Prince Ju's concubine) Consort Shi and his parents died in the incident as well in the capital Chang'an. It is not completely clear whether they took their own lives or were executed, but the latter seems likely. For reasons not completely clear, the baby Bingyi was spared, although he was imprisoned in a prison overseen by the Ministry of Vassal Affairs. He was put into the custody of the warden Bing Ji (). Bing knew that Prince Ju was actually innocent of witchcraft and took pity on the child, and selected two kind female prisoners, Hu Zu () and Guo Zhengqing () to serve as his wet nurses and caretakers. Bing visited them each day to see how the child was doing. Near the end of Emperor Wu's reign, there was an incident when magicians claimed that an aura of an emperor was appearing from Chang'an prisons. Emperor Wu ordered that all prisoners, regardless of whether they had been convicted or not and regardless of the severity of the charges, were to be executed. When the eunuch delivering the edict arrived at the Vassal Affairs prison that Bing oversaw, Bing refused to accept the edict, stating that no one who had not been convicted of a capital crime should be executed, and particularly not the emperor's own great-grandson. The eunuch filed charges against Bing for refusing to abide by the edict—a capital offense—but by that time Emperor Wu had realized his error and declared a general pardon. The prisoners in all other prisons were dead, but the prisoners at Bing's prison survived. However, this incident made Bing feel that it was inappropriate for the young Bingyi to remain at the prison, and so he ordered one of his lieutenants to transfer Bingyi and Hu (Guo might have died by this point) to the city government of Chang'an.