By the end of the 2nd century CE, the Han empire had declined after a period of chaos, from which three centres of political power emerged (Three Kingdoms). In 220 CE Xiandi, the last Han emperor, ceded the throne to Cao Pi, who thereby became the heir of the empire and the first ruler of the Wei dynasty in one region. Han generals took over two other regions, creating the Shu-Han and Wu empires.