According to the 1456 Treaty of Yazhelbitsy, the Novgorod Republic became dependent on the Grand Duchy of Moscow was not allowed to conduct independent foreign policy. In a bid to regain independence, Novgorod began negotiations for an anti-Muscovite alliance with Casimir IV Jagiellon, Grand Duke of Lithuania. It was alleged in an account purportedly drawn up in the archiepiscopal scriptorium in the mid-1470s that Mikhailo, as regent for Casimir IV, arrived in Novgorod initially to marry Marfa Boretskaya, the matriarch of the pro-Lithuanian faction in the city (or else to have her married to an unnamed Lithuanian nobleman). Moscow accused Novgorod not only of violation of a political treaty, but also of religious treachery: there were also allegations that the marriage would have brought Novgorod over to Catholicism, but Gail Lenhoff and Janet Martin argue that the pro-Lithuanian, pro-Catholic allegations are highly suspect and, indeed, very unlikely. Mikhailo was Orthodox (as was Marfa Boretskaya) and he and his brother had strong differences of opinion with Casimir IV Jagiellon. Mikhailo entered Novgorod on November 8, 1470 with a large retinue and remained in the city until March 15, 1471. His large retinue included Skhariya (Zechariah) the Jew, who gained a following in Novgorod. The heresy spread from there to Moscow in 1479 when Grand Prince Ivan III transferred several heretical priests to Moscow. The affair ended when Mikhailo withdrew from the city and Ivan III defeated the Novgorodians in the Battle of Shelon in July 1471. In 1478, Moscow took direct control of the city.