Keelung was first inhabited by the Ketagalan, a tribe of Taiwanese aborigine. The Spanish expedition to Formosa in the early 17th century was its first contact with the West; by 1624 the Spanish had built , a fort in Keelung serving as an outpost of the Manila-based Spanish East Indies. The Spanish ruled it as a part of Spanish Formosa. From 1642 to 1661 and 1663–1668, Keelung was under Dutch control. The Dutch East India Company took over the Spanish Fort San Salvador at Santissima Trinidad.