The 19th century saw the alliance between Portugal and the United Kingdom come into effect once more when Napoleon Bonaparte built the Continental System, which Portugal refused to join, leading Napoleon to invade. In 1807 Napoleon's army attacked Lisbon, forcing the Portuguese royal family to flee to Brazil under the protection of the British Royal Navy. In the later half of the century, as Portugal's imperial power declined following Brazil's independence, there were disputes between itself and the United Kingdom in southern Africa (1890 British Ultimatum) which was a great embarrassment for the Portuguese monarchy and colonial prestige. Portugal was one of the Allies of World War I along with Britain. While officially neutral in World War II, Portugal remained friendly to the British, a counterpart to Spain's cooperation with the Axis.