The term shanrang 禪讓 or shanwei 禪位 is used for the handing over of the throne to someone "who deserved it" because of high moral standing, and not because of the regular rules of succession.
Confucians saw these two examples as paradigms of how the rule over the world should be organized. Confucius himself praised Yao: "It is only Heaven that is grand, and only Yao corresponded to it." (Wei tian wei da, wei Yao ze zhi 唯天為大，唯堯則之。; Lunyu 論語, ch. Taibo 泰伯, transl. Legge 1895), and was convinced that the manner in which Shun and Yu held possession of the empire was "majestic" (weiwei 巍巍), and as if it were nothing to them (bu yu yan 不與焉).
Yet Confucius did not wholly discard the custom of inheritance, as it was introduced by Yu, who gave the throne to his son Qi 啟. According to Mengzi 孟子(ch. Wanzhang 萬章 A), the Master held that Yao (Tang 唐) and Shun (Yu 虞) resigned the throne to their worthy ministers, and the founders of the Xia 夏 (21th-17th cent. BCE), Shang 商 (17th-11th cent. BCE), and Zhou 周 (11th cent.-221 BCE) dynasties transmitted it to their sons, the principle of righteousness being the same in all the cases (qi yi yi ye 其義一) because it was in all cases "the people's wish" who should succeed to the throne.
Yu the Great planned for his loyal minister Yi 益 (Bo Yi 伯益, because the potential candidate minister Gao Yao 皋陶 died prematurely) to inherit the throne, but when Yu died, the people did not ask Yi to mount the throne, but they welcomed Qi, the son of Yu.
Even if being designated as the next ruler, worthies like Shun or Yi first withdrew to the southern wilderness or to the mountains, signifying that they did not aim for rulership. They waited until the people came to ask them before accepting their invitation. Qi was the first ruler who succeeded his father and thus created a "dynasty" (the Xia).
In spite of the mythological origin of the term, it was abused in later years to justify the usurpation of the throne by a powerful minister, like Cao Pi 曹丕 (187-226, evtl. Emperor Wen 魏文帝, r. 220-226), who ended the Han dynasty 漢 (206 BCE-220 CE) and founded the Wei dynasty 曹魏 (220-265). Formally, Emperor Xian 漢獻帝 (r. 189-220) handed over the state seals to Cao Pi and "ceded the throne" to him. In the respective edict, Emperor Xian explained that the Mandate of Heaven was not constant, but was given to a person of virtue ( 天命不于常，惟歸有德).
In the same manner, the regent Sima Yan 司馬炎 (236-290, evtl. Emperor Wu 晉武帝, r. 265-290) forced Emperor Yuan 魏元帝 (r. 260-265) to abdicate and founded the Jin dynasty 晉 (265-420). The Jin dynasty again was ended by Emperor Gong's 晉恭帝 (r. 418-419) handing over of the throne to the "morally superior" Liu Yu 劉裕 (363-422, evtl. Emperor Wu 宋武帝, r. 420-422), founder of the Liu-Song dynasty 劉宋 (420-479). Emperor Gong retired and adopted the title of Prince of Lingling 零陵. The last forced ceding of the throne was realized by Gao Yang 高洋 (526-559, evtl. Emperor Wenxuan 北齊文宣帝, r. 550-559), founder of the Northern Qi dynasty 北齊 (550-577) as successor of the Eastern Wei 東魏 (534-550).
Such abuses of the concept of ceding the throne to a morally superior person might have been inspired by ancient reports telling a different story, as in the chapter on the Five Emperors (1 Wudi benji 五帝本紀, Zhengyi commentary 正義) in the history book Shiji 史記, where it is said that when the virtue of Yao declined, Shun imprisoned him (Yao de shuai, wei Shun suo qin 堯德衰為舜所囚). Hanfeizi 韓非子 (ch. Shuoyi 說疑) even says that Shun forced Yao to retreat (Shun bi Yao 舜逼堯), Yu pushed aside Shun, Tang the Perfect forced away King Jie 桀 of the Xia, and King Wu 周武王 of the Zhou attacked the king of Shang, Zhou 紂. In these four cases, "ministers killed their lords" (ren chen shi qi jun 人臣弒其君).
The term shanwei was also used when a sovereign retired, like King Wuling 趙武靈王 (r. 326-299) of Zhao 趙 who retired in favour of his son King Huiwen 趙惠文王 (r. 299-266), but remained an active politician and military leader, or the Qianlong Emperor 乾隆帝 (r. 1735-1796), who stepped back on the Newyear's Day (Chinese calendar) 1796 to have his son Yong Yan 顒琰, the Jiaqing emperor 嘉慶帝 (r. 1796-1820), mount the throne. Qianlong died in 1799 and continued to dominate all court decisions.