After the demise of Nanzhao 南诏, the Buddhist kingdom that integrated the tribes of the Erhai region in the second half of the first millennium, local strongmen proclaimed a succession of short-lived statelets before Duan Siping 段思平 in 937 CE established the Dali Kingdom 大理国.
Nanzhao 南诏 emerged from competing tribes under leadership of the Meng clan 蒙氏 in the second half of the first millennium and after 255 years came to an end when its last, still adolescent, ruler was killed by a courtier in 902 CE.
A large part of what we know about the period of 35 years after Nanzhao's end comes from a Ming dynasty history compilation called《南诏野史》 ('Unofficial History of Nanzhao'). It records the end of Nanzhao with this sentence :
(Rough translation: The Meng clan Nanzhao Great Meng Kingdom, established by Xinuluo, from its founding in the 23rd year of the reign of Tang Taizong to its end in the second year of Zhaozong, a succession of thirteen generations, altogether 255 years.)
Contemporary mainland Chinese historians, in the usual Marxist pattern, attribute the decline of Nanzhao to its 'internal contradictions', which in their opinion led to an increased reliance on Buddhism and increasing warfare to keep the state alive (see 段玉明: 《南诏大理文化史》). Non-mainland scholars, such as Bin Yang take a more cautions approach, noting that Nanzhao's conflict with the Chinese empire probably contributed to demise of the Tang dynasty, which indicates strength rather than weakness of Nanzhao.
But the few records in the 南诏野史 do not give much detail about the state of affairs in the late Nanzhao period, and it seems that it was the conflict between influential clans that led to one clan after the next claim the throne, only to be deposed by another clan shortly after.
In the following, the quotes all come from the section of the 'Unofficial History of Nanzhao' about the period after the fall of the kingdom. The quotes form a successive narrative, that is to say, that what appears in the quotes below is all that is recorded about these statelets.
In 902 CE, the Nanzhao 'Prime Minister' 清平官 Zheng Maisi 郑买嗣 killed the last regent of Nanzhao and proclaimed a new kingdom, called 大长和国. While this brought Nanzhao formally to an end, it seems that apart from a change in rulers not much changed in the region: new temples continued to be established and the warfare against neighbouring states continued:
In 927 CE, a mere three generations and 26 years later, the last ruler of the Zheng clan Zheng Longmai 郑隆卖 was assassinated by the military commander 节度使 of Jianchuan, Yang Ganzhen 杨干贞. The Yang clan (with their names written in Chinese as 杨, 阳 or 羊) was from early on one of the influential clans in the Dali region, being mentioned many times in official documents.
But it was not the Yang clan who took power after the fall of 大长和国, it was the Zhao 赵 clan under the leadership of Zhao Shanzheng 赵善政, who had been 'prime minister' 清平官 under the previous ruler. In 927 CE, a new kingdom called 大天兴国 was proclaimed. The previous ruling clan was annihilated, but the Yang clan retained its power, who after only ten months deposed the Zhao clan. The 'Unofficial History of Nanzhao' records:
But even though Zhao Shanzheng's rule lasted not even a year, he and his extended family became Benzhu, Bai protector deities, in a number of villages in the Erhai region, for details see 《白族本主》.
In 929 CE Yang Ganzhen 杨干贞 proclaimed yet another kingdom, called 大义宁国. Legend has it that he was an illegitimate child, born at the Shamo Temple 沙漠庙 near modern Wase and later adopted by someone from Wocun 萂村, receiving military training etc before rising in the court of 大天兴国. 杨周伟's 《朝圣魂归: 南诏大理国》 fleshes this story out somewhat more, giving more credence to the legend that he was an illegitimate child of a ruler.
Yang Ganzhen's rule also did not last, but his legacy lives on in local patron saint worship. The village of Wocun, in Binchuan county, but actually not far from the shores of Erhai, considers him its patron saint. He is honoured annually in the 天子会 in village during the end of the spring festival period.
In 936 CE, the military commander of the Tonghai region, Duan Siping 段思平 dispatched troops to dispose the Yang clan and in 937 CE proclaimed the new Dali Kingdom 大理国, which was to last until 1254 when the Mongol army invaded Dali and brought hundreds of years of mostly independent rule in the Erhai region to an end.
Based on the little available details from the 《南诏野史》, there is little to suggest that the demise of Nanzhao is anything other than the result of a coup d'etat in the royal household, where a strong 'prime minister' got rid of the young king with the view to install himself as ruler. This in turn then emboldened other clans to do likewise, resulting in this succession of statelets, before the chief of the Duan clan 段氏, which possibly came from outside, manages to install his clan to rule for the next few hundred years.