Spanish East Indies together with the Spanish West Indies, were administered through the Viceroyalty of New Spain based in Mexico City. After Mexican independence, they were ruled directly from Madrid. As a result of the Spanish–American War in 1898, the Philippines and Guam were occupied by the United States while about 6,000 of the remaining smaller islands were sold to Germany in the German–Spanish Treaty of 1899. The few remaining islands were ceded to the United States when the Treaty of Washington was ratified in 1901. Spanish contact began on , when a Spanish expedition led by Ferdinand Magellan reached the Mariana Islands.
West Indies the Caribbean. From the 17th through the 19th century, the European colonial territories of the West Indies were the French West Indies, British West Indies, the Danish West Indies, the Netherlands Antilles (Dutch West Indies), and the Spanish West Indies. In 1916, Denmark sold the Danish West Indies to the United States for US$25 million in gold, per the Treaty of the Danish West Indies. The Danish West Indies became an insular area of the U.S., called the United States Virgin Islands. Between 1958 and 1962, the United Kingdom re-organised all their West Indies island territories (except the British Virgin