In 1895, under the Treaty of Shimonoseki which ended the First Sino-Japanese War, Taiwan was ceded by China to Japan. The Taiwanese attempted to resist the Japanese occupation, and a short-lived Democratic Republic of Formosa was declared by the Chinese governor Tang Jingsong on 25 May 1895. Tang became president of the new republic, and Liu Yongfu was made a brigadier general and given command of resistance forces in southern Taiwan. Ten days after declaring independence Tang Jingsong fled to Mainland China, and Liu replaced him as head of government (though he did not, as is often claimed, succeed to the presidency). At the end of May 1895 Japanese forces landed near Keelung, on the northern coast of Taiwan, and proceeded to conquer the island. Between June and August the Japanese defeated the Formosan forces in northern and central Taiwan, and in October 1895 three Japanese columns advanced on Tainan, sweeping aside Liu's forces. On 20 October 1895 Liu fled to the mainland aboard the British-flagged merchant ship "SS Thales" with the Japanese cruiser in close pursuit. "Yaeyama" caught "Thales" in international waters outside of Amoy, but her boarding party was unable to apprehend Liu, who was disguised as a coolie. The incident provoked a diplomatic protest from the United Kingdom and resulted in an official apology by the Japanese government. On 21 October Tainan capitulated to the Japanese. The collapse of Formosan resistance inaugurated five decades of Japanese rule in Taiwan.