In the late nineteenth and early 20th centuries, the U.S. started being more active in foreign affairs. In 1898, the United States fought a war with Spain called the Spanish–American War. The United States won, and gained Puerto Rico, Guam, Guantanamo and the Philippines. Combined with the purchase of Alaska and the taking-over of Hawaii, the United States had gained all the territory it has today, plus some it would later lose after World War II. Around this time, the U.S. and European nations opened up trade with China. This was because they had beaten China in the Opium Wars and the Boxer Rebellion. The U.S. and Europe were able to trade with China through the Open Door Policy.