Emperor Xian of Han
Cao Cao died on 15 March 220. His son and successor, Cao Pi, soon forced Emperor Xian to abdicate the throne in favour of himself, ending the Han dynasty. Cao Pi established a new state known as Cao Wei (sometimes known inaccurately as the Kingdom of Wei), and he granted Emperor Xian a noble title – Duke of Shanyang (山陽公). The former Emperor Xian died in 234 and was buried with honours befitting an emperor, using Han ceremonies, and the then emperor of Wei, Cao Rui, was one of the mourners. As Emperor Xian's crown prince was already dead, his grandson Liu Kang (劉康) inherited his dukedom, which lasted for 75 more years and two more dukes, Liu Jin (劉瑾) and Liu Qiu (劉秋), until the line was exterminated by invading Xiongnu tribes in about 309, during the Jin dynasty. This practice of an emperor conferring hereditary nobility on his predecessor, from whom he usurped the throne, was known as "er wang san ke" (二王三恪).
History of the Han dynasty
When Cao Cao moved Emperor Xian to Xuchang in 196 CE, he took the title of Excellency of Works as Dong Zhuo had before him. In 208 CE, Cao abolished the three most senior offices, the Three Excellencies, and instead recreated two offices, the Imperial Counselor and Chancellor; he occupied the latter post. Cao was enfeoffed as the Duke of Wei in 213 CE, had Emperor Xian divorce Empress Fu Shou in 214 CE, and then had him marry his daughter as Empress Cao Jie in 215 CE. Finally, Cao took the title King of Wei in 216 CE, violating the rule that only Liu family members could become kings, yet he never deposed Emperor Xian. After Cao Cao died in 220 CE, his son Cao Pi (186–226 CE) inherited the title King of Wei and gained the uneasy allegiance of Sun Quan (while Liu Bei at this point had taken over Liu Zhang's territory of Yi Province). With debates over prognostication and signs from heaven showing the Han had lost the Mandate of Heaven, Emperor Xian agreed that the Han dynasty had reached its end and abdicated to Cao Pi on December 11, 220 CE, thus creating the state of Cao Wei, soon to oppose Shu Han in 221 CE and Eastern Wu in 229 CE.