An attempt in May 1706 by Philip V of Spain to retake Barcelona failed, while his absence allowed an Allied force to capture Madrid and Zaragossa but they could not be resupplied so far from their bases and were forced to withdraw. By November 1706, Philip controlled the Crown of Castile, Murcia and parts of the Kingdom of Valencia. Over the course of 1706, Allied victories in the Spanish Netherlands and Italy forced the French onto the defensive and Galway sought to take advantage by launching a new offensive in 1707. To counter this, James FitzJames, 1st Duke of Berwick, was appointed commander of Bourbon forces in North-East Spain, a total of 33,000 men, split equally between French and Spanish troops, with a number of exiled Irish regiments.
