no different, abandoning Charles soon after his success, probably fearful of the king's rising power in northern Italy and of being encircled by an Angevin state. William allied with Alfonso X of Castile, who had declared himself the heir of Manfred of Sicily and therefore of the Emperor Frederick II, as the leaders of an anti-Angevin coalition. In order to cement the alliance also with the Spanish king, the Marquis (widowed since 1270) married Beatrice, Alfonso's daughter, at Murcia in August 1271. From Alfonso, William received the promise of military aid in the case of an Angevin attack. Alfonso named his son-in-law as vicar-general of Lombardy, in opposition to Charles' vicar. This last attacked William's lands and despite the promises, he received no aid from Alfonso. Left alone and seeing his domains under attack by his enemies and Tortona and Acqui lost, William scrambled to form an alliance with the Ghibelline cities of Pavia, Asti, and Genoa. He continued to wait for aid from Alfonso, but the king had given up on Germany and Italy. Nevertheless, a small troupe of Spanish soldiers found their way to Montferrat. With these and his allies, despite the excommunication of Pope Gregory X, William prepared to defend his territories. On 10 November 1274, at the Battle of Roccavione, William and the Ghibellines definitively defeated Charles I and routed his forces. He advanced far, taking Trino Vercellese and Turin, which offended the House of Savoy, which considered itself the rightful possessor of the city on the Po. Around 1278, the commune of Vercelli recognized William as lord, and Alessandria named him captain. Casale and Tortona also nominated him as captain. William thus ended the war in a superior position to that with which he had begun. Captain of Milan Having become the military leader of various Lombard cities, including Pavia, Vercelli, Alessandria, Tortona, Genoa, Turin, Asti, Alba, Novara, Brescia, Cremona, and Lodi, he was also elected head of the anti-Angevin coalition. Ottone Visconti asked William to fight the Torriani (1278), with an annual salary of 10,000 lire. However, he was defeated and forced to return to Montferrat. Milan, however, was left bereft of military leadership and Ottone Visconti soon requested William's aid again. He was invited back to the city and accepted, this time demanding the lordship of Milan for ten years in exchange. William did not long enjoy his time in Milan, for his