In response to the Dutch settlements, the Spanish settled at Keelung on the northeast coast of the island in 1626 and built Fort San Salvador. Later they built another outpost, Fort San Domingo, at Tamsui in the northwest. In 1629 these forts had a combined total of about 200 Spaniards and 400 Filipinos. By 1635, the Tamsui settlement was abandoned; however, the Keelung settlement remained in Spanish hands until 1642, when a Dutch force of 11 ships and 1,000 men attacked the fort of 446 people. The Spanish surrendered.
Following its defeat in the First Sino-Japanese War (1894–1895), China ceded Taiwan and the Pescadores to the Empire of Japan in perpetuity, with a grace period for inhabitants wishing to remain Chinese (Qing Dynasty) subjects to sell their property and return to the mainland. The date set for the handover was June 2, 1895.
However, the Republic of Formosa was formed on May 25, 1895 by a group of Qing officials and local gentry with its capital at Tainan to resist impending Japanese rule. The republic lasted for less than six months; on October 21, 1895 Imperial Japanese Army forces entered the capital and quelled the resistance. The Republic of Taiwan had two presidents:
After establishing control over the island, the Japanese used the French Empire model of an occupying force and were instrumental in the industrialization of the island; they built railroads, a sanitation system and a public school system, among other things. Around 1935, the Japanese began an island-wide assimilation project to bind the island more firmly to the empire.
In 1941, war broke out when the Japanese attacked the U.S. naval port of Pearl Harbor in Hawaii. By 1945, desperate plans were in place to incorporate popular representation of Taiwan into the Imperial Diet to end colonial rule of the island and transfer occupying troops to the front lines to fight the Allies. The names listed here are the Japanese governor-generals: