This period immediately followed the death of the King Charles II of Spain. It was the start of a new era within Spain, one that moved away from the Habsburg Dynasty. Spain wasn't coping so well, with several defeats to France and a declining economy that was constantly bombarded with the threat of bankruptcy due to the numerous wars in which Spain played a part. The crown was passed on to Philip of Anjou, grandson of King Louis XIV of France. The potential Habsburg candidate wanted to be crowned and felt cheated out of the position, causing problems that would eventually see England and Netherlands getting involved. The War of the Spanish succession commensed and there were several battles, including the Battle of Blenheim. The treaty of Utrecht was signed in 1713, France and Spain had agreed they would not unite under one throne and a significant portion of land was removed from Spain.
Phillip was good at harmonising the laws around Spain and sorted out problems that had occured during the last years of the Habsburg era. He was also, however, in favor of an aggressive foreign policy, meaning he had his country endure frequent wars which cost them financially and incurred great losses for his people. Phillip went to win back Sardinia, one of the areas originally lost to Austria. Soon afterwards Sicily was in his aims, though they were up against the quadruple alliance. Several invasions later, peace treaties were signed and eventually Austria said they would help reclaim land Britain had taken, though once it actually came to it they didnt keep their promises.
Following his recent choice of actions, Phillip then decided to take a more reserved approach when exercising his power and sought the help of allies to provide security for his country. Phillip was then succeeded by King Ferdinand IV, a generous man who provided assistance for regions like Andalusia in times of need. He also reforged links with France at a time when Spain was still defensively weak. With the prospect of limited resources it was a wise decision, though there were many who thought an allegiance with Britain would be more benefical, especially with their Navy. The seventy year war also occured during this period
King Ferdinand's wife passed away, and the king would do the same just one year later. His successor came in the form of Charles III. Charles quickly acquired Naples and Sicily by use of force. He didnt share an alliance with Britain. When the Seventy Year War started he first stayed neutral because of others controlling that decision. However, because he had a grudge with Britain over forcing him to stay neutral in an earlier war he intervened and helped France during the war. It wasn't a great decision, as the Spanish suffered heavy losses.
During this period the population was greatly increasing and reforms were needed to make sure that things didn't get out of control. There were land and agricultural reforms and some of these decisions led to badly recieved reactions. One example was the Motin de Esquilache, with which the change of trading policies left a grain shortage. This would spark riots that led to the King fleeing the country until all had calmed down. Next the American Revolutionary War was a chance for Spain to fight against Britain once again. They took advantage, invading and managing to claim back a large portion of what they had lost in the Seventy Year War.
Charles III passed away in 1788 and the French Revolution followed shortly after. Charles III's successor, Charles IV, was only really interested in hunting and his wife made quite a few of the decisions. She was busy having an affair with a fellow named Manuel de Godoy, of whom the king was quite fond despite the king's knowledge of what was goign on. In fact, Manuel de Godoy was appointed the Chief Minister in 1792. Once again there was another war between Spain and France, which ended with the signing of the Treaty of Basel. Godoy decided it would be a better idea to make a truce with France once again and asked for their support later on when they were trying to occupy parts of Italy. The British navy sparked off another battle, the legendary Battle of Trafalagar, and Spain suffered heavy losses. The relations didn't stay good after this and Napoleon didn't trust Spanish royalty. France pressured King Ferdinand to allow Napoleon's brother to become the King of Spain and later succeeded.
As Ferdinand was imprisoned and the French were slowly taking over, Britain, Portugal and Spain joined together to work together against France. Eventually Sir Arthur Wellesley invaded Spain and fought back the French forces; he saw it as a good time to hit them on the offensive, as they were busy unleashing an unsuccessful attack on Prussia. Around this time, Spain went to go onto lose most of their American colonies.