From 1516 to 1521, Nicolaus Copernicus lived at the town's castle as administrator and in Mehlsack (Melzak, now Pieniężno).
Copernicus was in charge of the Polish defenses in the Siege of Allenstein during the Polish-Teutonic War of 1519–21.
He also started and managed the repopulation of the region, inviting a new wave of Polish settlers from Mazovia.
The town along with Warmia then entered what is considered the region's golden age, crafts and trade developed, also due to the city's location on the Warsaw-Königsberg (Królewiec) trade route.
During this period, the city was still visited several times by Copernicus, as well as leading figures of Polish Renaissance, writers, royal secretaries and diplomats: Johannes Dantiscus, called the "father of Polish diplomacy", and Marcin Kromer, who was also a historian and music theorist.
The St. James' Cathedral, one of the most distinctive landmarks of the cityscape, was completed.

Prosperity was halted in the 1620s, when the town suffered a fire and an epidemic.
In 1626, during the Swedish invasion, canons from Frombork (Frauenburg) took refuge in the town, which the Swedes did not reach.
The city was sacked by Swedish troops later, in 1655 and 1708, during the next Polish-Swedish wars, and its population was nearly wiped out in 1710 by epidemics of bubonic plague and cholera.

The town became part of the Kingdom of Prussia in 1772 after the First Partition of Poland and its economy initially collapsed.
Poles became subject to extensive Germanisation policies.
A Prussian census recorded a population of 1,770 people, predominantly farmers, and Allenstein was administered within the newly created Province of East Prussia.
It was visited by Napoleon Bonaparte in 1807 after his victories over the Prussian Army at Jena and Auerstedt.
The growth of the city started again after it became a district seat in 1818, a significant influx of German settlers began and by 1825, the town was inhabited by 1,341 Germans and 1,266 Poles.
In the early 1830s the city suffered from a cholera epidemic and a hunger crisis, however afterwards it flourished again, under mayor Jakub/Jakob Rarkowski from 1836 to 1865.
Under Rarkowski the city was expanded and modernized, and the mayor also hid Polish insurgents in the city during the January Uprising.
The first German-language newspaper, the Allensteiner Zeitung, began publishing in 1841.
Polish historian Wojciech Kętrzyński was arrested in Jomendorf (the present-day district of Jaroty), and imprisoned in the city's High Gate in 1863 for smuggling weapons for the Polish January Uprising in the Russian Partition of Poland.
The town hospital was founded in 1867.

In 1871, with the unification of Germany, Allenstein became part of the German Empire.
Two years later, the city was connected by railway to Thorn (Toruń).
Despite Germanisation attempts the city remained an important Polish centre.
Its first Polish language newspaper, the Gazeta Olsztyńska, was founded in 1886.
Allenstein's infrastructure developed rapidly: gas was installed in 1890, telephones in 1892, public water supply in 1898, and electricity in 1907.
The Provincial Mental Sanatorium Kortau was established in 1886 just south of Allenstein (today part of Olsztyn-Kortowo).
In 1905, the city became the capital of Regierungsbezirk Allenstein, a government administrative region in East Prussia.
From 1818 to 1910, the city was administered within the East Prussian Allenstein District, after which it became an independent city.
From 1516 to 1521, Nicolaus Copernicus lived at the town's castle as administrator and in Mehlsack (Melzak, now Pieniężno). Copernicus was in charge of the Polish defenses in the Siege of Allenstein during the Polish-Teutonic War of 1519–21. He also started and managed the repopulation of the region, inviting a new wave of Polish settlers from Mazovia. The town along with Warmia then entered what is considered the region's golden age, crafts and trade developed, also due to the city's location on the Warsaw-Königsberg (Królewiec) trade route. During this period, the city was still visited several times by Copernicus, as well as leading figures of Polish Renaissance, writers, royal secretaries and diplomats: Johannes Dantiscus, called the "father of Polish diplomacy", and Marcin Kromer, who was also a historian and music theorist. The St. James' Cathedral, one of the most distinctive landmarks of the cityscape, was completed.
Prosperity was halted in the 1620s, when the town suffered a fire and an epidemic. In 1626, during the Swedish invasion, canons from Frombork (Frauenburg) took refuge in the town, which the Swedes did not reach. The city was sacked by Swedish troops later, in 1655 and 1708, during the next Polish-Swedish wars, and its population was nearly wiped out in 1710 by epidemics of bubonic plague and cholera.
The town became part of the Kingdom of Prussia in 1772 after the First Partition of Poland and its economy initially collapsed. Poles became subject to extensive Germanisation policies. A Prussian census recorded a population of 1,770 people, predominantly farmers, and Allenstein was administered within the newly created Province of East Prussia. It was visited by Napoleon Bonaparte in 1807 after his victories over the Prussian Army at Jena and Auerstedt. The growth of the city started again after it became a district seat in 1818, a significant influx of German settlers began and by 1825, the town was inhabited by 1,341 Germans and 1,266 Poles. In the early 1830s the city suffered from a cholera epidemic and a hunger crisis, however afterwards it flourished again, under mayor Jakub/Jakob Rarkowski from 1836 to 1865. Under Rarkowski the city was expanded and modernized, and the mayor also hid Polish insurgents in the city during the January Uprising. The first German-language newspaper, the Allensteiner Zeitung, began publishing in 1841. Polish historian Wojciech Kętrzyński was arrested in Jomendorf (the present-day district of Jaroty), and imprisoned in the city's High Gate in 1863 for smuggling weapons for the Polish January Uprising in the Russian Partition of Poland. The town hospital was founded in 1867.
In 1871, with the unification of Germany, Allenstein became part of the German Empire. Two years later, the city was connected by railway to Thorn (Toruń). Despite Germanisation attempts the city remained an important Polish centre. Its first Polish language newspaper, the Gazeta Olsztyńska, was founded in 1886. Allenstein's infrastructure developed rapidly: gas was installed in 1890, telephones in 1892, public water supply in 1898, and electricity in 1907. The Provincial Mental Sanatorium Kortau was established in 1886 just south of Allenstein (today part of Olsztyn-Kortowo). In 1905, the city became the capital of Regierungsbezirk Allenstein, a government administrative region in East Prussia. From 1818 to 1910, the city was administered within the East Prussian Allenstein District, after which it became an independent city.
Olsztyn