The Ibaloi called the place Kafagway. The name Baguio comes from their word bagiw, moss, which the Spanish wrote as Baguio. The Spanish never fully conquered the mountains. They set up a command post in nearby La Trinidad in 1846 and counted Kafagway as a minor settlement of about 20 houses, mostly on land owned by the Ibaloi leader Mateo Cariño. The town hall now stands where his house was.
The Americans came looking for a cool place in the northern mountains. An expedition led by the zoologist Dean Worcester went in 1900, and in 1901 the colonial government took land from the Ibaloi, who were forced to sell. Kennon Road, the first road to link Baguio directly with the lowlands, was built from 1903 by Filipino, Japanese and Chinese workers, and many of the Chinese and Japanese stayed.
Daniel Burnham, a leading American planner, drew up the city in 1904 on City Beautiful lines. Baguio became a chartered city in 1909. The Mansion, Wright Park, Burnham Park, Governor Pack Road and Session Road all date from this period. Burnham planned for 25,000 to 30,000 people. The 2020 census counted 366,358.
War reached Baguio on the first day. On 8 December 1941, 17 Japanese bombers hit Camp John Hay. In early March 1945 American aircraft unloaded 933 tons of explosives plus 1,185 gallons of napalm, and much of the city was left in ruins. It was retaken by 27 April, and the Japanese surrender in the Philippines was signed that September at Camp John Hay.
After the war the city recovered quickly as a tourist destination, though it stopped being the official Summer Capital in 1976. Under martial law, which began in September 1972, part of the city jail held political detainees, many without charge. In February 1986 organizers camped in the courtyard of the cathedral, and Session Road became the centre of the People Power uprising in Baguio. The next year Baguio became the seat of the new Cordillera Administrative Region.
On 16 July 1990 an earthquake of magnitude 7.7 hit. Hotels including the Hyatt Terraces Plaza and the Nevada Hotel were badly damaged, and landslides temporarily blocked the highways. Some of the buildings that fell stood on or near fault lines, and local architects later admitted building codes had not been followed closely enough. Aid came from Japan, Singapore and the United States. The Panagbenga flower festival was created partly as a way to lift the city after the quake. Today most of the skyline is contemporary.