Chiang Mai is both a city and a province in Northern Thailand. The city, nicknamed "The Rose of the North", is often spoken of by the Thai as their "second city", though compared to the megalopolis Bangkok (population about 10 million), it is a distant second, with about 200,000 inhabitants. The problems which detract from Bangkok's charm - pollution, traffic, overcrowding - are only beginning to be felt in Chiang Mai. It remains a pretty city ringed by the Suthep mountain range, dotted by wat (Buddhist temples), and animated by a regional pride. The river Ping runs through the city and eventually joins forces with other waterways to culminate in the mighty Chao Phraya, which flows through Bangkok and into the Gulf of Thailand.
The people of Chiang Mai have their own distinct language - Yuan - and think of themselves as Thai, but also Yuan. The city and surrounding areas are home to many peoples besides ethnic Thai and Thai Yuan, including Shan and Karen of Burmese ancestry and dozens, perhaps hundreds, of other minority groups who have fled from strife in neighbouring countries to settle in the hills. These peoples, usually called hill tribes in Thai English, live in simple rustic villages which are favourite stopping places for the treks so popular with tourists. Once making their meagre living largely from cash cropping opium and heroin, and denied Thai citizenship, today they are included in the Thai nation and have come to rely for survival on development projects sponsored by the king of Thailand, Bhumibol Adulyadej, and on tourism. Chiang Mai's Night Market is filled with colourful crafts made by hilltribe people.
I lived in Bangkok for four years, then in Chiang Mai for a year, and I was struck by Chiang Mai-ians fierce pride in their unique cultural heritage. They are the inhabitants of a long-standing indigenous kingdom, Lanna or Lan Na, founded in the 13th century by the great king Mangrai. Mangrai consolidated the northern prinicpalities using a judicious mix of friendship and force - at times conquering his neighbours, at times forging alliances with them. After establishing cities and capitals throughout what is now northern Thailand, Mangrai, in consultation with neighbouring rulers Ramkhamhaeng and Ngam Muang, decided on the site for his final capital, Chiang Mai or "New City" in 1292. They drafted plans for the fortified city, though construction was not begun until 1296, for Mangrai was kept busy repelling the Mongols who were trying to invade.
The city of Chiang Mai was planned by the three rulers - Mangrai, Ramkhamhaeng, and Ngam Muang - to be easily defensible. It was ringed by a wall and a moat, with entrance only gained through gates, several of which remain in the centre of the much larger modern city. Mangrai's city included the lovely Wat Chiang Man, a beautiful example of Lanna architecture still standing today, and soon other historic temples like Wat Phra Singh were built. A day trip around the city reveals many more gorgeous teak gems.
Although now a part of Thailand, in those days Lanna was an independent kingdom, and had many battles with Siam - first centred at Sukhothai, then Ayuthaya - over territory and independence. Chiang Mai was an important city on the trading routes between Yunnan and Burma (Myanmar), which sent goods to India and beyond. It was also a religious centre, and in 1477 hosted the Seventh World Buddhist Council.
But this golden age waned. In 1545 there was a devastating earthquake which destroyed much of the city, and in 1557 the Burmese kingdom took over Chiang Mai, placing their king on the throne and exacting annual tribute from Lanna. Chiang Mai was tributary at times to Burma and at times to Ayuthaya over the next few centuries, eventually becoming a Burmese stronghold and staging ground for the offensive on Ayuthaya in 1767 which destroyed that city and forced the Siamese kingdom to regroup around Thonburi and then Bangkok.
The city of Chiang Mai was deserted for twenty years after the Burmese onslaught on Ayuthaya, then was gradually repopulated under Siamese tutelage. But travel to Chiang Mai was so difficult - the first missionaries who reached there from Bangkok in the 19th century took three months to make the journey - that the prince of Chiang Mai was virtually independent. So Lanna languished as a backwater, out of touch with neighbouring powers, until the reigns of Mongkut and Chulalongkorn in the latter half of the 19th century. During this period the French became firmly established in Indochina - what is now Vietnam, Cambodia, and Laos - while the British consolidated control over India and Burma, and the central Siamese government realized the strategic importance of the north. Determined to retain Lanna and hold off covetous European powers, Chulalongkorn had the borders of the ancient kingdom mapped and began the construction of a railroad which by 1921 would link the north to the centre. He removed all power from the prince - the last hereditary ruler died in 1939 - and made Chiang Mai a province and integral part of the kingdom of Siam, now Thailand.
http://www.chiangmainews.com/cultural/700.php
http://www.track-of-the-tiger.com/html/history.html