Málaga, as headquarters of the "Capitanía General de Granada" (Captaincy General of the Kingdom of Granada) on the coast, played an essential role in the foreign policy of the Bourbon kings of Spain. The regional military and the defence of the Mediterranean were administered in the city. The loss of Gibraltar to the British in the Battle of Málaga of 1704 made the city the key to military defence of the Strait.