In 1898 , after 400 years of colonial rule that saw the indigenous population nearly exterminated and African slave labor introduced , Puerto Rico was ceded to the US as a result of the Spanish-American War .