It remained in the Polish–Lithuanian Commonwealth until 1795 when, in the First Partition of Poland it became part of Kingdom of Prussia (the region in which the town is located was split between Prussia and Russia) until 1807. At this time the town was incorporated into the Duchy of Warsaw and merged into the Białystok region. After Napoleon's defeat in 1815 the region switched hands again and became part of Russia, and then Congress Poland, as part of the Augustów, and later Suwałki, district. In 1856, the vast majority of the town's population was Jewish, with 4,417 Jews and 834 Christians. During World War I the town was captured by German forces and held until 1918, when the place became part of independent Lithuania. During the interwar period a rail line was constructed running through nearby Marijampolė which caused that town to become the regional center, replacing Vilkaviškis in its traditional role.