Huang Hao entered the Shu imperial palace sometime in the 220s as a eunuch attending to the Shu emperor Liu Shan, who favoured him because he was shrewd and full of flattering words. Whenever Huang Hao attempted to interfere in state affairs, Dong Yun, then the head of government, warned Liu Shan about the dangers of flattery and admonished Huang Hao for misleading the emperor. When Dong Yun was still alive, he kept Huang Hao in check and never allowed him to be promoted beyond the position of an Assistant of the Yellow Gate. Following Dong Yun's death in 246, Chen Zhi replaced him as the head of government and collaborated with Huang Hao to dominate the imperial court and state affairs. During this time, Liu Shan also criticised the late Dong Yun for treating him with contempt; he was believed to have said this under the influence of Huang Hao and Chen Zhi. When Chen Zhi died in 258, Huang Hao became the most influential figure in the Shu central governmentChengdu. Liu Shan also promoted him to the positions of Central Regular Attendant and Commandant of Equippage. Huang Hao abused his power by promoting officials who flattered him and demoting those who refused to fawn on him. When Luo Xian refused to associate with him, he had Luo Xian sent out of Chengdu to serve as the Administrator of Badong Commandery. Yan Yu, a close friend of Huang Hao, was appointed as Luo Xian's deputy to watch over him. Fan Jian, the Prefect of the Masters of Writing, refused to have any dealings with Huang Hao. Huang Hao disliked Xi Zheng, an official who had been neighbours with him for about 30 years, so although he did not harm Xi Zheng, he never allowed Xi Zheng to get promoted. Liu Yong, a younger brother of Liu Shan, hated Huang Hao and was never on good terms with him. After Huang Hao came to power, he slandered and spoke ill of Liu Yong in front of Liu Shan, resulting in Liu Shan refusing to meet Liu Yong for more than 10 years. In 262, the Shu general Jiang Wei wrote to Liu Shan to urge him to execute Huang Hao. However, Liu Shan refused, said that Huang Hao were merely a servant running errands for him, and told Jiang Wei to not take it too personally. Jiang Wei knew that Huang Hao had many supporters in the imperial court and became worried that he might have gotten himself into trouble when he asked Liu Shan to execute Huang Hao. Later, Liu Shan ordered Huang Hao to apologise to Jiang Wei. Jiang Wei found an excuse to leave Chengdu and move to a military garrison at Tazhong. In the meantime, Huang Hao came up an idea to remove Jiang Wei from his command and replace him with Yan Yu, his close friend. When Jiang Wei heard about it, he remained in Tazhong and refused to return to Chengdu as he knew that he would be safe in Tazhong. In 263, Jiang Wei received news that Zhong Hui, a general from Shu's rival state Wei, was mobilising troops into the Guanzhongregion, seemingly in preparation for an invasion of Shu. He then wrote to Liu Shan, requesting permission to set up defences against the impending invasion. Huang Hao, who believed in sorcery, got a witch doctor to predict the future. He then told Liu Shan that the witch doctor predicted that the Wei forces would not attack Shu, so there was no need to follow Jiang Wei's plan. Later that year, the Wei general Deng Ai led his troops through a shortcut across mountainous terrain, bypassed the Shu defences, and showed up outside Chengdu. Liu Shan surrendered without putting up a fight, thus bringing an end to the Shu regime's existence. After Liu Shan's surrender, Deng Ai heard that Huang Hao was a treacherous person and wanted to execute him, but Huang Hao had already bribed Deng Ai's men to release him and escaped. His eventual fate is unknown. In Chapter 119 of the 14th-century historical novelRomance of the Three Kingdoms, Huang Hao is publicly executed at the order of the Wei regent Sima Zhao when he followed Liu Shan to the Wei capital Luoyang.