Spanish East Indies exception of a short period at the end of the 18th century). In 1821 the New Spanish Viceroyalty collapsed following the Mexican War of Independence, which resulted in the First Mexican Empire. All control of the Spanish East Indies government was then transferred to Madrid, until the United States annexed most Spanish territories in the Asia-Pacific region after the Spanish–American War of 1898. In 1574 the Captaincy General of the Philippines was created as a dependency of the Viceroyalty of New Spain. The Real Audiencia of Manila was created on and established in 1584 as the highest tribunal of the
Dutch East Indies East Indies. In 1811 Daendels was replaced by Governor-General Jan Willem Janssens, but shortly after his arrival British forces occupied several Dutch East Indies ports including Java, and Thomas Stamford Raffles became Lieutenant Governor. Following Napoleon's defeat at the 1815 Battle of Waterloo and the Congress of Vienna, independent Dutch control was restored in 1816. Under the 1824 Anglo-Dutch Treaty, the Dutch secured British settlements such as Bengkulu in Sumatra, in exchange for ceding control of their possessions in the Malay Peninsula (Malaya) and Dutch India. The resulting borders between former British and Dutch possessions remain today between modern Malaysia