Following the election of Pope Nicholas V in 1447, Margarit resigned his offices in Girona in order to again try to gain an entry to the papal court.[1] He traveled to Rome in 1448, and on September 14, 1449, Alfonso V of Aragon named him procurator of the Kingdom of Naples in Rome.[1] He also served as an ambassador of John II of Castile to Rome.[1] On January 3, 1450, he became a member of the Apostolic Camera; he took the oath on October 5, 1450.[1]
He then returned to Catalonia and participated in the Corts of Barcelona of 1454-58.[1] In 1455, Alfonso V of Aragon sent him to the Kingdom of Naples.[1] Alfonso's successor, John II of Aragon, appointed Margarit as his ambassador to Pope Pius II in 1458.[1] He accompanied the pope to the Council of Mantua (1459).[1]
On January 12, 1460, John II of Aragon recommended that the pope make Bishop Margarit a cardinal.[1] Instead, Pope Pius II named him nuncio to the Kingdom of Aragon, charged with a double mission: (1) reconciling the king with his estranged son, Charles, Prince of Viana; and (2) promoting a crusade against the Ottoman Empire to retake the Kingdom of Cyprus and restore the dethroned Charlotte of Cyprus.[1] He was transferred to the see of Girona on September 23, 1461, and was thereafter Bishop of Girona until his death.[1] Bishop Margarit remained with John II throughout the Catalan Civil War, and took active part in some battles, such as the defense of the queen, Joana Enríquez, and John II's heir, Prince Ferdinand, during the siege of the Força of Girona in 1462.[1]
Following the end of the Catalan Civil War in 1472, John II attempted to convince the pope to make Bishop Margarit a cardinal, again unsuccessfully.[1] Instead he became a royal counselor, who took an active part in Aragonese politics until John II's death in 1479.[1] He served as Chancellor of Aragon under John II and his successor Ferdinand II.[1]
In 1481, Ferdinand II despatched him to the Republic of Venice to dissuade the Venetians from continuing to have trading relations with the Ottoman Empire.[1] He remained in Venice until late 1482.[1] In November 1482, Pope Sixtus IV signed a peace treaty with Alfonso II of Naples and a month later with Ferdinand II. The pope was about to abandon the Venetian cause when the intervention of the Catholic Monarchs and Bishop Margarit were able to secure a peace treaty.[1]