In 1334, a watchtower was established on the Łyna River.
In 1346, the forest was cleared at the location for a new settlement, mentioned in a historical document from 1348.
The following year, Teutonic Knights began the construction of an Ordensburg castle as a stronghold against the Baltic Prussians.
Allenstein was granted municipal rights by the cathedral chapter of the Bishopric of Warmia in October 1353.
The German "Allenstein" referred to the river's Baltic Prussian name Alna, which meant a hind.
Local Poles called it Holstin and Olsztyn.
The castle was completed in 1397.
The town was captured by the Kingdom of Poland during the Polish-Lithuanian-Teutonic War in 1410, and again in 1414 during the Hunger War, but it was returned to the monastic state of the Teutonic Knights after hostilities ended.

Allenstein joined the Prussian Confederation in 1440 and rebelled against the Teutonic Knights in 1454 upon the outbreak of the Thirteen Years' War to join Poland under King Casimir IV Jagiellon.
The townspeople took the castle and recognized the Polish king as the rightful ruler.
Although the Teutonic Knights recaptured the town the following year, it was retaken by Polish troops in 1463.
The Second Peace of Thorn in 1466 confirmed Olsztyn as part of the Kingdom of Poland.
Administratively it was located in the Prince-Bishopric of Warmia within the provinces of Royal Prussia and Greater Poland.
In 1334, a watchtower was established on the Łyna River. In 1346, the forest was cleared at the location for a new settlement, mentioned in a historical document from 1348. The following year, Teutonic Knights began the construction of an Ordensburg castle as a stronghold against the Baltic Prussians. Allenstein was granted municipal rights by the cathedral chapter of the Bishopric of Warmia in October 1353. The German "Allenstein" referred to the river's Baltic Prussian name Alna, which meant a hind. Local Poles called it Holstin and Olsztyn. The castle was completed in 1397. The town was captured by the Kingdom of Poland during the Polish-Lithuanian-Teutonic War in 1410, and again in 1414 during the Hunger War, but it was returned to the monastic state of the Teutonic Knights after hostilities ended.
Allenstein joined the Prussian Confederation in 1440 and rebelled against the Teutonic Knights in 1454 upon the outbreak of the Thirteen Years' War to join Poland under King Casimir IV Jagiellon. The townspeople took the castle and recognized the Polish king as the rightful ruler. Although the Teutonic Knights recaptured the town the following year, it was retaken by Polish troops in 1463. The Second Peace of Thorn in 1466 confirmed Olsztyn as part of the Kingdom of Poland. Administratively it was located in the Prince-Bishopric of Warmia within the provinces of Royal Prussia and Greater Poland.
Olsztyn