Pope John died on 20May 1277. Charles was ill and could not prevent the election of Giovanni Gaetano Orsini as Pope Nicholas III on 25November. The Pope soon declared that no foreign prince could rule in Rome and reminded Charles that he had been elected senator for ten years. Charles swore fealty to the new pope on 24May 1278 after lengthy negotiations. He had to pledge that he would renounce both the senatorship of Rome and the vicariate of Tuscany in four months. On the other hand, Nicholas III confirmed the excommunication of Charles' enemies in Piedmont and started negotiations with Rudolf to prevent him from making an alliance against Charles with Margaret of Provence and her nephew, Edward I of England. The negotiations with Rudolf lay behind Nicholas' refusal to renew Charles' vicariate in Tuscany, to which Rudolf had appointed his own vicar.