Charles's distant cousin, Louis I of Hungary, who had not fathered a son, decided to invite Charles to Hungary. Charles came to Hungary in 1364 or 1365. King Louis initially planned to arrange a marriage between Charles and Anne, who was a daughter of Charles IV, Holy Roman Emperor. However, the negotiations of their marriage were broken off because the relations between Louis I and Charles IV had deteriorated. Next, Louis proposed a marriage between Charles and Charles's cousin, Margaret of Durazzo, who was the youngest daughter of Queen Joanna's younger sister, Maria of Calabria. Although the queen was opposed to the marriage, Pope Urban VI granted the papal dispensation that was necessary for the marriage on 15 June 1369. Their marriage took place in Naples on 24 January 1370.