The Battle of Alcácer Quibir in 1578 saw both the death of the young king Sebastian and the end of the House of Aviz.
Sebastian's successor, the Cardinal Henry of Portugal, was 70 years old.
 Henry's death was followed by a dynastic crisis, with three grandchildren of Manuel I claiming the throne: Catherine, Duchess of Braganza, who was married to John, 6th Duke of Braganza; António, Prior of Crato; and Philip II of Spain.
António had been acclaimed King of Portugal by the people of Santarém on July 24, 1580, followed by many other cities and towns throughout the country.
However, Philip II marched into Portugal and defeated the troops loyal to the Prior of Crato in the Battle of Alcântara.
 Philip II was crowned Philip I of Portugal in 1580 (he was subsequently recognized as official king by the Portuguese Cortes of Tomar in 1581) and the Philippine Dynasty began.

Portugal's status was maintained under the first two kings of the Philippine Dynasty, Philip I and his son Philip II of Portugal and III of Spain.
Both monarchs gave excellent positions to Portuguese nobles in the Spanish courts, and Portugal maintained independent laws, currency, and government.
However, the joining of the two crowns deprived Portugal of a separate foreign policy, and Spain's enemies became Portugal's.
The war with England led to a deterioration of relations with Portugal's oldest ally (since the Treaty of Windsor in 1386) and the loss of Hormuz.

Being united with Spain involved Portugal in the Eighty Years War, Spain's war with the emerging Dutch Republic - which began with the Dutch rebelling against Spanish rule in their own north European territory, but soon developed into the Dutch Republic becoming a major new maritime power and attacking the Spanish colonies.
This campaign directly impacted Portuguese colonies as well, many of which were invaded by the Dutch - leading to the Dutch–Portuguese War.
In Asia, Portuguese Ceylon (modern Sri Lanka) - where the Portuguese had long controlled the coastal regions (though not the whole island) - was lost to the Dutch, as were Portuguese colonies in the East Indies (today's Indonesia), and commercial interests in Japan.
Portuguese colonies in Africa (Mina) and South America were also attacked by the Dutch.
Brazil was partially conquered by both France and the Dutch Republic.
The Dutch intrusion into Brazil was longer lasting and more troublesome to Portugal.
The Dutch captured a large portion of the Brazilian coast including Bahia, Salvador, Recife, Pernambuco, Paraíba, Rio Grande do Norte, Ceará, and Sergipe, while Dutch privateers captured Portuguese ships in both the Atlantic and Indian Oceans.

When Philip II died, he was succeeded by Philip III (and IV of Spain) who took a different approach to Portuguese issues.
He raised taxes, which mainly affected Portuguese merchants (Carmo Reis 1987).
The Portuguese nobility began to lose its importance at the Spanish Cortes, and government posts in Portugal were occupied by Spaniards.
Ultimately, Philip III tried to make Portugal a Spanish province and Portuguese nobles lost all of their power.

This situation culminated in a revolution by the Portuguese nobility and high bourgeoisie on 1 December 1640, 60 years after the crowning of Philip I. The revolution was planned by Antão Vaz de Almada, Miguel de Almeida and João Pinto Ribeiro.
They, together with several associates, killed Secretary of State Miguel de Vasconcelos and imprisoned the king's cousin, the Duchess of Mantua, who had governed Portugal in his name.
The moment was well chosen, as Spain was fighting the Thirty Years' War and also facing the Catalan Revolt at the time.

The support of the people became apparent almost immediately and soon John, 8th Duke of Braganza, was acclaimed King of Portugal throughout the country as John IV.
By December 2, 1640, John was already sending a letter as sovereign of the country to the Town Hall of Évora.
The Battle of Alcácer Quibir in 1578 saw both the death of the young king Sebastian and the end of the House of Aviz. Sebastian's successor, the Cardinal Henry of Portugal, was 70 years old.  Henry's death was followed by a dynastic crisis, with three grandchildren of Manuel I claiming the throne: Catherine, Duchess of Braganza, who was married to John, 6th Duke of Braganza; António, Prior of Crato; and Philip II of Spain. António had been acclaimed King of Portugal by the people of Santarém on July 24, 1580, followed by many other cities and towns throughout the country. However, Philip II marched into Portugal and defeated the troops loyal to the Prior of Crato in the Battle of Alcântara.  Philip II was crowned Philip I of Portugal in 1580 (he was subsequently recognized as official king by the Portuguese Cortes of Tomar in 1581) and the Philippine Dynasty began.
Portugal's status was maintained under the first two kings of the Philippine Dynasty, Philip I and his son Philip II of Portugal and III of Spain. Both monarchs gave excellent positions to Portuguese nobles in the Spanish courts, and Portugal maintained independent laws, currency, and government. However, the joining of the two crowns deprived Portugal of a separate foreign policy, and Spain's enemies became Portugal's. The war with England led to a deterioration of relations with Portugal's oldest ally (since the Treaty of Windsor in 1386) and the loss of Hormuz.
Being united with Spain involved Portugal in the Eighty Years War, Spain's war with the emerging Dutch Republic - which began with the Dutch rebelling against Spanish rule in their own north European territory, but soon developed into the Dutch Republic becoming a major new maritime power and attacking the Spanish colonies. This campaign directly impacted Portuguese colonies as well, many of which were invaded by the Dutch - leading to the Dutch–Portuguese War. In Asia, Portuguese Ceylon (modern Sri Lanka) - where the Portuguese had long controlled the coastal regions (though not the whole island) - was lost to the Dutch, as were Portuguese colonies in the East Indies (today's Indonesia), and commercial interests in Japan. Portuguese colonies in Africa (Mina) and South America were also attacked by the Dutch. Brazil was partially conquered by both France and the Dutch Republic. The Dutch intrusion into Brazil was longer lasting and more troublesome to Portugal. The Dutch captured a large portion of the Brazilian coast including Bahia, Salvador, Recife, Pernambuco, Paraíba, Rio Grande do Norte, Ceará, and Sergipe, while Dutch privateers captured Portuguese ships in both the Atlantic and Indian Oceans.
When Philip II died, he was succeeded by Philip III (and IV of Spain) who took a different approach to Portuguese issues. He raised taxes, which mainly affected Portuguese merchants (Carmo Reis 1987). The Portuguese nobility began to lose its importance at the Spanish Cortes, and government posts in Portugal were occupied by Spaniards. Ultimately, Philip III tried to make Portugal a Spanish province and Portuguese nobles lost all of their power.
This situation culminated in a revolution by the Portuguese nobility and high bourgeoisie on 1 December 1640, 60 years after the crowning of Philip I. The revolution was planned by Antão Vaz de Almada, Miguel de Almeida and João Pinto Ribeiro. They, together with several associates, killed Secretary of State Miguel de Vasconcelos and imprisoned the king's cousin, the Duchess of Mantua, who had governed Portugal in his name. The moment was well chosen, as Spain was fighting the Thirty Years' War and also facing the Catalan Revolt at the time.
The support of the people became apparent almost immediately and soon John, 8th Duke of Braganza, was acclaimed King of Portugal throughout the country as John IV. By December 2, 1640, John was already sending a letter as sovereign of the country to the Town Hall of Évora.
History of Portugal (1640–1777)