They were in conflict over the succession to the Spanish throne - this is known as "the war of Spanish succession"
This war was caused by the death of the Childless Charles II - who was a Habsurg and a King of Spain.
Part of this conflict was the conflict over the ownership of Gibraltar- which Spain lost during this war.