The treaty was one of a series of agreements signed between 1662 and 1668, driven by changes in the European balance of power.
These included the weakening of the relationship between France and the Dutch Republic, allies in the Eighty Years' War, and Spain's eclipse by France under Louis XIV.

By the middle of the 17th century, the Spanish Empire remained a huge global confederation but needed peace after a century of continuous warfare.
The Franco-Spanish War of 1635-59 concluded with the Treaty of the Pyrenees; the Anglo-Spanish War of 1654-60 involving the Commonwealth of England was suspended after the Restoration of Charles II in 1660.

Spain now focused on ending the long-running Portuguese Restoration War; in 1656, Philip IV agreed to help Charles regain his throne, in return for assistance against Portugal.
However, in May 1661, Charles agreed to marry Catherine of Braganza and provide Portugal military support.

This was the result of various factors, one being Philip's insistence on the return of Jamaica, captured in 1656, and Dunkirk, captured in 1658; previously part of the Spanish Netherlands, Charles sold it to France in 1662.
Relinquishing Jamaica was viewed with great hostility in England, where Parliament voted to annex it in September 1660.
English merchants gained access to Portuguese markets in Brazil, Africa and the Far East; the acquisition of Tangier and Bombay provided bases in the Mediterranean and on the Surat coast.
This made it too attractive to refuse but impacted Anglo-Spanish relations.
The treaty was one of a series of agreements signed between 1662 and 1668, driven by changes in the European balance of power. These included the weakening of the relationship between France and the Dutch Republic, allies in the Eighty Years' War, and Spain's eclipse by France under Louis XIV.
By the middle of the 17th century, the Spanish Empire remained a huge global confederation but needed peace after a century of continuous warfare. The Franco-Spanish War of 1635-59 concluded with the Treaty of the Pyrenees; the Anglo-Spanish War of 1654-60 involving the Commonwealth of England was suspended after the Restoration of Charles II in 1660.
Spain now focused on ending the long-running Portuguese Restoration War; in 1656, Philip IV agreed to help Charles regain his throne, in return for assistance against Portugal. However, in May 1661, Charles agreed to marry Catherine of Braganza and provide Portugal military support.
This was the result of various factors, one being Philip's insistence on the return of Jamaica, captured in 1656, and Dunkirk, captured in 1658; previously part of the Spanish Netherlands, Charles sold it to France in 1662. Relinquishing Jamaica was viewed with great hostility in England, where Parliament voted to annex it in September 1660. English merchants gained access to Portuguese markets in Brazil, Africa and the Far East; the acquisition of Tangier and Bombay provided bases in the Mediterranean and on the Surat coast. This made it too attractive to refuse but impacted Anglo-Spanish relations.
Treaty of Madrid (1667)