Since 1702 a war had been fought over who would inherit the Spanish throne with Britain and the Dutch supporting the Austrian candidate while France and her allies supported a French candidate. In 1704 the Anglo-Dutch fleet had captured Gibraltar and defeated a Spanish fleet at the Battle of Málaga. Allied forces had also landed in Catalunya where they captured Barcelona in 1705. The Catalans largely supported the Austrian claimant and many joined the Allied armies.