Incorporated into the Province of East Prussia from 1815, Ragnit became a part of the German Empire upon the Prussian-led unification of Germany in 1871. Its castle, having long lost its defensive purpose, became a court and prison. On November 1, 1892, a railroad line linking the town with Tilsit (now Sovetsk) was opened. It was built to develop the wood industry in the area, but the development did not actually start and the area's economy remained dominated by food production. When Germany had to cede the Klaipėda Region north of the Neman River to the Conference of Ambassadors according to the 1919 Treaty of Versailles, Ragnit became a border town. In 1922, it lost its status as an administrative capital in favor of Tilsit.