In 1580, King Philip II of Spain invaded Portugal after a crisis of succession brought about by King Sebastian of Portugal's death during a disastrous Portuguese attack on Alcácer Quibir in Morocco in 1578. At the Cortes of Tomar in 1581, Philip was crowned Philip I of Portugal, uniting the two crowns and overseas empires under Spanish Habsburg rule in a dynastic Iberian Union. At Tomar, Philip promised to keep the empires legally distinct, leaving the administration of the Portuguese Empire to Portuguese nationals, with a Viceroy of Portugal in Lisbon seeing to his interests. Philip even had the capital moved to Lisbon for a two-year period (1581–83) due to it being the most important city in the Iberian peninsula. All the Portuguese colonies accepted the new state of affairs except for the Azores, which held out for António, a Portuguese rival claimant to the throne who had garnered the support of Catherine de Medici of France in exchange for the promise to cede Brazil. Spanish forces eventually captured the islands in 1583.