Rzhev was founded in the Middle Ages and rivals Toropets as the oldest town in the region. Rzhevians usually point out that their town is mentioned in the Novgorod laws as early as 1019. Their neighbors from Toropets, on the other hand, give more credence to Rzhev's first mention in a major chronicle under 1216, when it was in possession of Mstislav the Bold, Prince of Toropets. Whatever the truth may be, it is clear that medieval Rzhev was bitterly contested by three regional powers—the Novgorod Republic, the Principality of Smolensk, and the Grand Principality of Vladimir-Suzdal. Following the Mongol invasion, Rzhev passed to a lateral branch of the Smolensk dynasty, which made the town its capital. Later the princes divided the town in two parts, which are still called the Prince-Dmitry's Side and Prince-Theodor's Side. In the mid-14th century, they had a hard time repelling attacks from Algirdas of Lithuania and Grand Princes of Tver, who bought all the villages around the town. Finally, they left for Moscow, where their descendants (the Rzhevsky family) have become comic characters of many a joke. In the meantime, the town was occupied for a short space by Tver, Poland-Lithuania, and finally by the Grand Duchy of Moscow.