The Philippine Islands became a Spanish colony during the 16th century ; they were ceded to the US in 1898 following the Spanish-American War .