The millennium-old civilisation came crashing down in the 9th century when the city-states were destroyed by repeated invasions from the Kingdom of Nanzhao. The Burmans (Bamar) set up a garrison town at Pagan (Bagan) at the confluence of the Irrawaddy and Chindwin Rivers. Pyu settlements remained in Upper Burma for the next three centuries but the Pyu gradually were absorbed into the expanding Pagan Kingdom. The Pyu language still existed until the late 12th century. By the 13th century, the Pyu had assumed the Burman ethnicity. The histories and legends of the Pyu were also incorporated to those of the Burmans.