Tibet formed from communities living along the Yarlung Tsangpo, the longest river in Tibet. Namri Songtsen united these communities under one king around 600 CE, with the city of Lhasa becoming capital. His son Songtsen Gampo took control of land beyond Lhasa and the Yarlung Tsangpo and started the Tibetan Empire. Tibetan writers say that Buddhists came to Tibet for the first time while Songtsen Gampo was king. Trisong Detsen, king from 755-794 CE, gave a lot of support to Buddhism. He helped build a monastery at Samye, which became very important. During Trisong Detsen's time as king, the Tibetan Empire had control over large areas of land. Tibet's borders touched Central Asia and Afghanistan at the west, Bangladesh at the south, and China at the east. After the king Langdarma was killed in 842, the Tibetan Empire collapsed, and Tibet was no longer united under one king.