Following China's defeat in the First Sino-Japanese War, Taiwan was ceded to Japan in April 1895 under the Treaty of Shimonoseki. A number of Chinese officials in Taiwan decided to resist the Japanese, and proclaimed Taiwan an independent Republic of Formosa. Tang was inaugurated as the republic's president on May 25, 1895. The republic lasted no longer than the time it took the Japanese to invade and occupy Taiwan. The Japanese invaded northern Taiwan on May 29, 1895 and defeated Chinese forces at Keelung on 3 June.