The country was originally settled approximately 3,000 years ago by migrants from Maritime Southeast Asia. Spain was the first European nation to invade the islands in the 16th century, and they were made part of the Spanish East Indies in 1574. Following Spain's defeat in the Spanish–American War in 1898, the islands were sold to Germany in 1899 under the terms of the German–Spanish Treaty, where they were administered as part of German New Guinea. After World War I, the islands were made a part of the Japanese-ruled South Seas Mandate by the League of Nations. During World War II, skirmishes, including the major Battle of Peleliu, were fought between American and Japanese troops as part of the Mariana and Palau Islands campaign. Along with other Pacific Islands, Palau was made a part of the United States-governed Trust Territory of the Pacific Islands in 1947. Having voted in a referendum against joining the Federated States of Micronesia in 1978, the islands gained full sovereignty in 1994 under a Compact of Free Association with the United States.