Ptuj is the oldest city in Slovenia. There is evidence that the area was settled in the Stone Age. In the Late Iron Age it was settled by Celts.By the 1st century BC, the settlement was controlled by Ancient Rome. In 69 AD, Vespasian was elected Roman Emperor by the Danubian legions in Ptuj, and the first written mention of the city of Ptuj is from the same year. The city of Poetovio was the base-camp of Legio XIII Gemina in Pannonia. The name originated in the times of Emperor Trajan, who granted the settlement city status and named it Colonia Ulpia Traiana Poetovio in 103. The city had 40,000 inhabitants until it was plundered by the Huns in 450.
In 570 the city was occupied by Eurasian Avars and Slavic tribes. Ptuj became part of the Frankish Empire after the fall of Avar state at the end of 8th century. Between 840 and 874 it belonged to the Slavic Balaton Principality of Pribina and Kocelj. Between 874 and 890 Ptuj gradually came under the influence of the Archbishopric of Salzburg; city rights passed in 1376 began an economic upswing for the settlement. As Pettau, it was incorporated into the Duchy of Styria in 1555.
Pettau was a battleground during the Ottoman wars in Europe and suffered from fires in 1684, 1705, 1710, and 1744.Its population and importance began to decline in the 19th century, however, after the completion of the Vienna-Trieste route of the Austrian Southern Railway, as the line went through Marburg (Maribor) instead.
According to the 1910 Austro-Hungarian census, 86% of the population of Pettau’s Old Town was German-speaking, while the population of the surrounding villages predominantly spoke Slovene. After the collapse of Austria-Hungary at the end of World War I, Pettau was included in the short-lived Republic of German Austria, but after the military intervention of the Slovenian general Rudolf Maister, the entire territory of Lower Styria was included into the State of Slovenes, Croats and Serbs (Yugoslavia). During the interwar period, the number and the percentage of those identifying as Germans in the city, which was renamed Ptuj, decreased rapidly, although a relatively strong ethnic German minority remained.
After the invasion of Yugoslavia in April 1941, Ptuj was occupied by Nazi Germany. From 1941 to 1944 the town’s Slovenian population was dispossessed and deported. Their homes were taken over by German speakers from South Tyrol and the Gottschee County, who had themselves been evicted according to an agreement between Adolf Hitler and Benito Mussolini. These German immigrants, along with the native German Pettauer, were expelled to Austria in 1945; many later settled in North America.
Since 1945 Ptuj has been populated almost completely by Slovenians.