Olsztyn (; Old Polish: Holstin; Old Prussian: Alnāsteini or Alnestabs; ) is a city on the Łyna River in northeastern Poland. Olsztyn has been the capital of the Warmian-Masurian Voivodeship since 1999. It was previously in the Olsztyn Voivodeship (and in other units in 1945–75 and 1975–98). The city has county status.
In 1346 the old Prussian Warmian forest in the vicinity was cleared and a place was selected on the Alle, now Łyna River, for a new settlement. The Teutonic Knights began the construction of Ordensburg castle in 1347 as a stronghold against the Old Prussians, and the settlement of Allenstein was first mentioned the following year. The German name Allenstein meant a castle on the Alle River. It became known in Polish transliteration as Olsztyn. The settlement received municipal rights from Johannes von Leysen on 31 October 1353, and the castle was completed in 1397. Allenstein was incorporated into the Kingdom of Poland during the Polish-Lithuanian-Teutonic War in 1410 and in 1414 during the Hunger War, but was returned to the monastic state of the Teutonic Knights after hostilities ended.
Allenstein joined the Prussian Confederation in 1440. It rebelled against the Teutonic Knights in 1454 upon the outbreak of the Thirteen Years' War and requested protection from the Polish Crown. Although the Teutonic Knights captured the town in the following year, it was retaken by Polish troops in 1463. The Second Peace of Thorn (1466) allocated Allenstein and the Bishopric of Warmia as part of Royal Prussia under the sovereignty of the Crown of Poland. From 1516–21, Nicolaus Copernicus lived at the castle as administrator of Allenstein and Mehlsack (Pieniężno); he was in charge of the defenses of Allenstein and Warmia during the Polish-Teutonic War of 1519–21.
Allenstein was annexed by the Kingdom of Prussia in 1772 during the First Partition of Poland. A Prussian census recorded a population of 1,770 people, predominantly farmers, in Allenstein, which was administered within the Province of East Prussia. It was visited by Napoleon Bonaparte in 1807 after his victories over the Prussian Army at Jena and Auerstedt. In 1825 the city was inhabited by 1266 Poles and 1341 Germans The German language newspaper, Allensteiner Zeitung, was first published in 1841. The town hospital was founded in 1867.
Allenstein became part of the German Empire in 1871 during the Prussian-led unification of Germany. Two years later the city was connected by railway to Thorn (Toruń). 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 city became the capital of Regierungsbezirk Allenstein, a government administrative region in East Prussia, in 1905. From 1818–1910 the city was administered within the East Prussia Allenstein District, after which it became an independent city.
Shortly after the outbreak of World War I, troops of the Russian Empire captured Allenstein in 1914, but it was recovered by the Imperial German Army in the Battle of Tannenberg. The battle actually took place much closer to Allenstein than Tannenberg (now Stębark), but the victorious Germans, having been defeated in the medieval battle of Tannenberg, named it as such for propaganda purposes). In 1920 during the East Prussian plebiscite, Allenstein voted to remain in German East Prussia instead of becoming part of the Second Polish Republic. The football club SV Hindenburg Allenstein played in Allenstein from 1921–45. After the Nazi seizure of power in 1933, Poles and Jews in Allenstein were increasingly persecuted. In 1935 the Wehrmacht made the city the seat of the Allenstein Militärische Bereich. It was the home of the 11th Infanterie Division, the 11th Artillery Regiment, and the 217th Infanterie Division.
The plebiscite was held on 11 July, and produced 362,209 votes (97.8%) for East Prussia and 7,980 votes (2.2%) for Poland. The stamps became invalid on 20 August. Despite their short period of use, almost all of the stamps are cheaply available both used and unused.
On 12 October 1939, after the invasion of Poland that began World War II, the Wehrmacht established an Area Headquarters for Wehrkreis I that controlled the sub-areas of Allenstein, Lötzen (Giżycko) and Zichenau (Ciechanów). Beginning in 1939, members of the Polish-speaking minority, especially members of the Union of Poles in Germany, were deported to Nazi concentration camps.
Allenstein was plundered and burnt by the invading Soviet Red Army on 22 January 1945, as the Eastern Front reached the city. Allenstein's German population evacuated the region or were subsequently expelled. On 2 August 1945, the city was placed under Polish administration by the Soviets (according to the Potsdam Agreement) and officially renamed to Polish Olsztyn. In October 1945, the German population of Olsztyn was expelled by Order of the City Commanders of Olsztyn and ordered to assemble on 18 October at Karl Roensch Street barracks camp for transfer to Germany and in the case of non-compliance were to be put in a "punishment camp".
A tyre factory was founded in Olsztyn in 1967.