In the end of the 16th century, king Sebastian of Portugal died in battle helping Abu Abdallah to return his throne after it was taken by the new Sultan of Morocco. This devastating event left Portugal without a rightful heir, which led to the succession crisis. Many people were not convinced that their king were dead and opposed the government at that time.
Right after the death of the king, there were quite a few heirs claimed their right to the throne. However, the throne was then given to Antonio, who was a grandson of Manuel I of Portugal. Unfortunately, the Council of Governors was not happy with the new king and ran back to the Spanish kingdoms at the time to proclaim Philip II as the new king of Portugal.
This situation led to the Battle of Alcântara, which was fought between Antonio’s troops and those of Philip II. Antonio was defeated and flew to Terceira island where he managed to keep his sovereignty for some time. However, the Spanish followed him even there and fought a couple of battles by sea until they took over the Azores islands. The islands were the second-to-last Portuguese territory, as Macau was the last one. Once the last part of the Portuguese Empire was defeated, Portugal became part of the then Iberian Union consisting of the Kingdom of Spain and Portugal under the Spanish Crown.
During the Iberian Union which lasted for around 60 years until 1640, the Azores islands became a port of call for the Spanish fleets. Even though Portugal at the time has been under the Spanish Crown, it was still autonomous and had its very own government, until the fall of the union in the 17th century. Then, the Azores Islands became a fully Portuguese territory again 😏