Iberian Union followed by Portuguese Restoration War
The Iberian Union was the dynastic union of the Crowns of Castile and Aragon and the Kingdom of Portugal that existed between 1580 and 1640 and brought the entire Iberian Peninsula, as well as Portuguese and Spanish overseas possessions, under the Spanish Habsburg monarchs Philip II, Philip III, and Philip IV. The union began after the Portuguese crisis of succession and the ensuing War of the Portuguese Succession, and lasted until the Portuguese Restoration War, during which the House of Braganza was established as Portugal's new ruling dynasty with the acclamation of John IV as the new King of Portugal. This was a personal union, so the Kingdoms of Portugal and Spain remained independent states, sharing only a single monarch.
The kings from the Spanish branch of the House of Habsburg were the only element that connected the multiple kingdoms and territories, ruled by the six separate government councils of Castile, Aragon, Portugal, Italy, Flanders-Burgundy, and the Indies. For periods, Portugal maintained a viceroy, appointed by the King, although the turnover was often rapid; in the 60 years of the Union, the country had 13 viceroys and four regency councils (see List of viceroys of Portugal). The governments, institutions, and legal traditions of each kingdom remained independent of one another. Alien laws (Leyes de extranjería) determined that a national of one kingdom was a foreigner in all other kingdoms.Restoration War and the end of the Union
The subsequent Portuguese Restoration War against Philip III (Portuguese: Guerra da Restauração) consisted mainly of small skirmishes near the border. The most significant battles were the Battle of the Lines of Elvas (1659), the Battle of Ameixial (1663), the Battle of Castelo Rodrigo (1664), and the Battle of Montes Claros (1665); the Portuguese were victorious in all of these battles. However, the Spaniards won the Battle of Vilanova (1658) and the Battle of the Berlengas (1666). The Battle of Montijo (1644) was indecisive, starting out with great Spanish success and ending with Portuguese success; the number of casualties were nearly equal.
Several decisions made by John IV to strengthen his forces made these victories possible. On 11 December 1640, the Council of War was created to organize all the operations. Next, the king created the Junta of the Frontiers, to take care of the fortresses near the border, the hypothetical defense of Lisbon, and the garrisons and sea ports. In December 1641, a tenancy was created to assure upgrades on all fortresses that would be paid with regional taxes. John IV also organized the army, established the Military Laws of King Sebastian, and developed intense diplomatic activity focused on restoring good relations with England. Meanwhile, the best Spanish forces were pre-occupied with their battles against the French in Catalonia, along the Pyrenees, Italy and the Low Countries. The Spanish forces in Portugal never received adequate support. Nevertheless, Philip IV felt he could not give up what he regarded as his rightful inheritance. By the time the war with France ended in 1659, the Portuguese military were well established and ready to confront the last major attempt of a worn out Spanish regime to reclaim control.
English soldiers were sent to Portugal and helped the Portuguese rout Don John's army at Ameixial near Estremoz on June 8, 1663. The Spaniards lost 8,000 men and all their artillery while the Portuguese had only 2,000 casualties. On 7 July 1664 about 3,000 Portuguese met 7,000 Spaniards near Figueira de Castelo Rodrigo and killed 2,000 and took 500 prisoners. Many Spanish communities lost population and blamed their decline on the war against Portugal. Louis XIV sent French troops to Lisbon, and on 17 June 1665 the German General Friedrich Hermann Schomberg led about 20,000 Portuguese forces to victory at Montes Claros near Vila Viçosa with only 700 killed and 2,000 wounded. The Spanish army of 22,600 men was devastated with 4,000 dead and 6,000 captured. Protests erupted in Madrid as Spain had wasted 25 million ducats on the disastrous Portuguese war. The Spanish tried to carry on the war for two years more. Spain recognized Portugal's sovereignty and made peace on 13 February 1668.