In 1895, Taiwan was ceded to Japan in the Treaty of Shimonoseki. The 1906 Meishan earthquake devastated the entire city wall except the Eastern Gate. The Japanese authorities reconstructed the city. Industries and trades started to flourish. According to the census taken in 1904, Kagi was the fourth most populous city in Taiwan, with a population of over twenty thousand.