gained a foothold in Karelia. On August 12, 1323, Sweden and Novgorod signed the Treaty of Nöteborg, regulating their border for the first time. The city's downfall occurred partially as a result of its inability to feed its large population, making it dependent on the Vladimir-Suzdal region for grain. The main cities in the area, Moscow and Tver, used this dependence to gain control over Novgorod. Eventually Ivan III forcibly annexed the city to the Grand Duchy of Moscow in 1478. The was dissolved and a significant part of Novgorod's aristocracy, merchants and smaller landholding families was deported to central Russia. The Hanseatic League kontor was closed in 1494 and the goods stored there were seized by Muscovite forces. Tsardom of Russia At the time of annexation, Novgorod became the third largest city under Muscovy and then the Tsardom of Russia (with 5,300 homesteads and 25–30 thousand inhabitants in the 1550s) and remained so until the famine of the 1560s and the Massacre of Novgorod in 1570. In the Massacre, Ivan the Terrible sacked the city, slaughtered thousands of its inhabitants, and deported the city's merchant elite and nobility to Moscow, Yaroslavl and elsewhere. The last decade of the 16th century was a comparatively favourable period for the city as Boris Godunov restored trade privileges and raised the status of Novgorod bishop. The German trading post was reestablished in 1603. Even after the incorporation into the Russian state Novgorod land retained its distinct identity and institutions, including the customs policy and administrative division. Certain elective offices were quickly restored after having been abolished by Ivan III. During the Time of Troubles, Novgorodians submitted to Swedish troops led by Jacob De la Gardie in the summer of 1611. The city was restituted to Muscovy six years later by the Treaty of Stolbovo. The conflict led to further depopulation: the number of homesteads in the city decreased from 1158 in 1607 to only 493 in 1617, with the Sofia side described as 'deserted'. Novgorod only regained a measure of its former prosperity towards the end of the century, when such ambitious buildings as the Cathedral of the Sign and the Vyazhischi Monastery were constructed. The most famous of Muscovite patriarchs, Nikon, was active in Novgorod between 1648 and 1652. The Novgorod Land became one of the Old Believers' strongholds after the Schism. The city remained an important trade centre even though it