After a few decades of relative autonomy came to a halt in 1898, Puerto Rico had been a Spanish colony since the 16th century, when the United States declared war on Spain - ostensibly to free Cuba from colonial rule. On July 25, 1898, American forces invaded and occupied Puerto Rico during the months following the Spanish - American War. As part of the peace treaty in December 1898, the colony was transferred to the United States and a military government took over.