Nidzica was founded in 1355 by the Teutonic Knights and received town privileges in 1381 from Winrich von Kniprode. Although a member of the Prussian Confederation, it remained with the Teutonic Order after the Second Peace of Thorn (1466). It then became part of the Duchy of Prussia after the secularization of the Order's Prussian territories in 1525.
In 1656 Neidenburg was unsuccessfully besieged during the Northern Wars. The town became part of the Kingdom of Prussia in 1701. Half of Neidenburg's inhabitants died from plague from 1708-1711. It became part of the German Empire in 1871 during the unification of Germany.
At the beginning of World War I in 1914, Neidenburg was heavily damaged by invading Imperial Russian troops; the town was reconquered and rebuilt by the Germans after the Battle of Tannenberg in 1914.