King Mangrai was born on October 2, 1238 in Ngoen Yang Thailand on the Mekong River, a son of the local ruler Lao Meng and his wife Ua Ming Chom Mueang, a princess from the Tai Luecity ofChiang Rung, which is now called Jinghong, in Sipsongpanna, China. In 1259, Mangrai succeeded his father to become the first independent king of the unified Taicity states in northern Lanna and what is now northern Laos. Seeing the Tai states were disunited and in danger, Mangrai quickly expanded his kingdom by conquering Muang Lai, Chiang Kham and Chiang Khong and initiating alliances with other states. In 1262, he founded the city of Chiang Rai as his new capital in the Kok River basin. He also seems to have been operating around this time in the area of Fang in the Upper Kok Valley. In 1287, Mangrai first made peace between King Ngam Muang of Phayao and King Ram Khamhaeng of Sukhothai, who had seduced the former's queen. The three Kings then entered a "Strong pact of friendship". While still living in the area of Fang he was visited by merchants from the Mon kingdom of Haripunchai. Hearing of the wealth of that kingdom, he determined to conquer it, against the advice of his counselors. As it was thought impossible to take the city by force, Mangrai sent a merchant named Ai Fa as a mole to gain the confidence of its King Yi Ba. In time, Ai Fa became the Chief Minister and managed to undermine the King's authority. In 1291, with the people in a state of discontent, Mangrai defeated the Mon kingdom and added Haripunchai to his kingdom. Yi Ba, the last king of Hariphunchai, was forced to flee south to Lampang.
Chiang Mai Era
After defeating the Hariphunchai kingdom, Mangrai decided to relocate his capital, and in 1294, Wiang Kum Kam was founded on the eastern bank of the Ping River. The site was plagued with floods, and a new site was chosen several kilometres to the northwest at the foot of Doi Suthep, on the site of an older fortified town of the Lua people. Construction of Chiang Mai began in 1296. and it has been the capital of the northern provinces more or less ever since. A few years later, Yi Ba's son, King Boek of Lampang, attacked Chiang Mai with a large army. King Mangrai and his second son, Prince Khram, led the defence against the Lampang army. Prince Khram defeated King Boek in personal combat on elephant-back at Khua Mung, a village near Lamphun. King Boek fled by way of the Doi Khun Tan mountain range between Lamphun and Lampang, but he was caught and executed. King Mangrai's troops occupied the city of Lampang, and King Yi Ba was made to flee further south, this time to Phitsanulok.
Death and succession
King Mangrai's eldest son grew tired of waiting and tried to seize the throne, but his attempt failed and he was executed. Mangrai's second son, Khun Kham, was then named to succeed Mangrai. King Mangrai died in 1311 in Chiang Mai. According to tradition, he was struck by lightning during a thunderstorm when he was in the city's market. Mangrai's death was followed by period of confusion, with six kings ruling in the next eleven years. This could have been disastrous if the northern powers had not had their own troubles. Sukhothai to the south had also been weakened. Not until the ascension of the Mangrai's grandson, Kham Fu, in 1328 did the kingdom achieve the stability it had had during the lifetime of its founder.