Spain allied with France through family pacts, and saw the revolution as an opportunity to weaken the British Empire, which had caused significant losses to Spain during the Seven Years' War.
As the newly appointed prime minister of Spain, the Count of Floridablanca, wrote in March 1777, "the fate of the interests of the colonies is very important to us, and we will do for them all that circumstances permit"
Spanish Prime Minister, Count of Floridablanca
The main objectives of Spain were recovering Gibraltar and Menorca from the British, who had owned it since 1704, after the Seven Years' War, between 1756 and 1763.
Panorama of the Grand Assault by French and Spanish warships, showing 1 ship exploding, infantry and artillery on land in right foreground
The Great Siege of Gibraltar was the first Spanish action in the war, which lasted from June 16, 1779 to February 7, 1783. In spite of having numerical superiority on French-Spanish Alliance, Britain did not lose Gibraltar.