Mangrai or Mengrai was born in 1239 and died in 1317 in what is now northern Thailand. He consolidated and ruled over the northern Thai kingdom of Lan Na or Lanna from 1259 until his death, moving his capital numerous times before founding the city of Chiang Mai as his seat of government.
Mangrai inherited the throne from his father at Chiang Saen - today a very small northern Thai town - during a time of much unrest. He quickly conquered his immediate neighbours, then established more southerly capitals at Chiang Rai in 1262 and Fang soon after.
Thereafter Mangrai became legendary for securing important alliances with powerful neighbours. The story goes that he was determined to seize the kingdom of Phayao from Ngam Muang, so in 1276 he marched to the city with an army. But Ngam Muang came out to meet him and the two men struck up a friendship and instead of fighting, forged an alliance. A few years later, Mangrai was called on to settle a dispute between Ngam Muang and Ramkhamhaeng of Sukhothai, who had seduced Ngam Muang's wife. Though Ngam Muang would have been within his rights to kill Ramkhamhaeng for this infraction, Mangrai thought little would be gained by that, and instead convinced Ramkhamhaeng apologize and pay an indemnity of 990,000,000 cowrie shells. Though the legends may be fanciful, the alliances were real, and helped these northern kingdoms hold off Mongol invasions from their strongholds in Burma, and Vietnamese and Khmer attacks from Angkor Wat.
Mangrai had been plotting for years to seize the ancient kingdom of Haripunjaya, centred in present-day Lamphun; he had planted a trusted courtier there who sowed confusion and dissent, finally signalling Mangrai that the time was right to invade. With Lamphun in his hands, Mangrai had finally consolidated his rule over what is now northern Thailand, and he then set about securing more alliances with his powerful neighbouring rulers, particularly the king of Pegu (part of present day Myanmar). Finally, in 1292, he chose a site for his final capital, Chiang Mai or "New City", in consultation with Ramkhamhaeng and Ngam Muang. Together they drafted plans for the city, and a statue of the three rulers in downtown Chiang Mai commemorates this historic collegial act. Actual construction did not begin until 1296, however, for Mangrai was busy for many years repelling the Mongols. The final assault in 1301 saw 20,000 men and 10,000 horses, reinforced by Mongol archers, roundly defeated by the northern Thai. Thereafter the Chinese resorted to diplomacy, and Chiang Mai began to send periodic tribute to China to forestall more hostilities.
Like Ramkhamhaeng, Mangrai adopted Theravada Buddhism and promoted the building of temples and religious monuments. He wrote just, humane laws, known today as "The Judgement]s of King Mangrai", which constitute an important indigenous Thai legal tradition. His efforts germinated the northern Thai (Thai Yuan) identity which is still important today.
Legend has it that Mangrai was killed when he was struck by lightning in the city centre at a spot today marked by a sacred pillar.
Like many strong leaders, his work of consolidation did not last, for after his death power struggles erupted among his descendants. In contrast to Mangrai's long reign, six kings held the throne in eleven years following his death; not until 1328 was Mangrai's great-grandson Khamfu able to impose a degree of stability on the kingdom that Mangrai had built.
Much of this information is from the standard source on Thai history, David K. Wyatt's Thailand: A Short History.